1+ import {
2+ listenerCancelled ,
3+ listenerCompleted ,
4+ } from '@internal/listenerMiddleware/exceptions'
5+ import type {
6+ AbortSignalWithReason ,
7+ AddListenerOverloads ,
8+ } from '@internal/listenerMiddleware/types'
9+ import { noop } from '@internal/listenerMiddleware/utils'
10+ import type {
11+ Action ,
12+ ListenerEffect ,
13+ ListenerEffectAPI ,
14+ PayloadAction ,
15+ TypedRemoveListener ,
16+ TypedStartListening ,
17+ UnknownAction ,
18+ } from '@reduxjs/toolkit'
119import {
220 TaskAbortError ,
321 addListener ,
@@ -10,28 +28,6 @@ import {
1028 removeListener ,
1129} from '@reduxjs/toolkit'
1230import type { Mock } from 'vitest'
13- import { vi } from 'vitest'
14-
15- import type {
16- Action ,
17- ListenerEffect ,
18- ListenerEffectAPI ,
19- PayloadAction ,
20- TypedAddListener ,
21- TypedRemoveListener ,
22- TypedStartListening ,
23- UnknownAction ,
24- } from '@reduxjs/toolkit'
25-
26- import {
27- listenerCancelled ,
28- listenerCompleted ,
29- } from '@internal/listenerMiddleware/exceptions'
30-
31- import type {
32- AbortSignalWithReason ,
33- AddListenerOverloads ,
34- } from '@internal/listenerMiddleware/types'
3531
3632const middlewareApi = {
3733 getState : expect . any ( Function ) ,
@@ -51,8 +47,6 @@ const middlewareApi = {
5147 throwIfCancelled : expect . any ( Function ) ,
5248}
5349
54- const noop = ( ) => { }
55-
5650// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
5751export interface Deferred < T > extends Promise < T > {
5852 resolve ( value ?: T | PromiseLike < T > ) : void
@@ -119,9 +113,7 @@ describe('createListenerMiddleware', () => {
119113 const testAction2 = createAction < string > ( 'testAction2' )
120114 const testAction3 = createAction < string > ( 'testAction3' )
121115
122- beforeAll ( ( ) => {
123- vi . spyOn ( console , 'error' ) . mockImplementation ( noop )
124- } )
116+ const consoleErrorSpy = vi . spyOn ( console , 'error' ) . mockImplementation ( noop )
125117
126118 beforeEach ( ( ) => {
127119 listenerMiddleware = createListenerMiddleware ( )
@@ -136,6 +128,14 @@ describe('createListenerMiddleware', () => {
136128 } )
137129 } )
138130
131+ afterEach ( ( ) => {
132+ consoleErrorSpy . mockClear ( )
133+ } )
134+
135+ afterAll ( ( ) => {
136+ consoleErrorSpy . mockRestore ( )
137+ } )
138+
139139 describe ( 'Middleware setup' , ( ) => {
140140 test ( 'Allows passing an extra argument on middleware creation' , ( ) => {
141141 const originalExtra = 42
0 commit comments