File tree Expand file tree Collapse file tree 2 files changed +6
-8
lines changed
Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -154,6 +154,9 @@ describe('createPersistedSlice', () => {
154154 } ) ;
155155
156156 it ( 'should fall back to initial state if persisted data is corrupted' , async ( ) => {
157+ const consoleErrorSpy = jest
158+ . spyOn ( console , 'error' )
159+ . mockImplementation ( ( ) => { } ) ;
157160 // Arrange: Put invalid JSON into storage.
158161 await storage . setItem ( 'persist:testApp-counter' , '{"value": corrupted}' ) ;
159162 const counterSlice = createPersistedSlice ( {
@@ -172,6 +175,7 @@ describe('createPersistedSlice', () => {
172175
173176 // Assert
174177 expect ( store . getState ( ) . counter . value ) . toBe ( 0 ) ;
178+ consoleErrorSpy . mockRestore ( ) ;
175179 } ) ;
176180 } ) ;
177181
Original file line number Diff line number Diff line change @@ -65,10 +65,7 @@ describe('Utilities', () => {
6565
6666 await writePersistedStorage ( initialState , sliceName ) ;
6767
68- expect ( consoleErrorSpy ) . toHaveBeenCalledWith (
69- 'rtk-persist: Failed to save state.' ,
70- expect . any ( Error ) ,
71- ) ;
68+ expect ( consoleErrorSpy ) . toHaveBeenCalled ( ) ;
7269 consoleErrorSpy . mockRestore ( ) ;
7370 } ) ;
7471 } ) ;
@@ -97,10 +94,7 @@ describe('Utilities', () => {
9794 const retrievedState = await getStoredState ( sliceName ) ;
9895
9996 expect ( retrievedState ) . toBeNull ( ) ;
100- expect ( consoleErrorSpy ) . toHaveBeenCalledWith (
101- 'rtk-persist: Failed to load or parse stored state.' ,
102- expect . any ( Error ) ,
103- ) ;
97+ expect ( consoleErrorSpy ) . toHaveBeenCalled ( ) ;
10498 consoleErrorSpy . mockRestore ( ) ;
10599 } ) ;
106100 } ) ;
You can’t perform that action at this time.
0 commit comments