diff --git a/packages/toolkit/src/query/tests/queryFn.test.tsx b/packages/toolkit/src/query/tests/queryFn.test.tsx index 6d382425e4..ceba81ff1a 100644 --- a/packages/toolkit/src/query/tests/queryFn.test.tsx +++ b/packages/toolkit/src/query/tests/queryFn.test.tsx @@ -190,9 +190,7 @@ describe('queryFn base implementation tests', () => { const thunk = endpoint.initiate(endpointName) - const result = (await store.dispatch(thunk)) satisfies - | undefined - | QuerySubState + const result: undefined | QuerySubState = await store.dispatch(thunk) if (endpointName.includes('Throw')) { expect(consoleErrorSpy).toHaveBeenCalledOnce() @@ -246,10 +244,10 @@ describe('queryFn base implementation tests', () => { const thunk = endpoint.initiate(endpointName) - const result = (await store.dispatch(thunk)) satisfies + const result: | undefined | { data: string } - | { error: string | SerializedError } + | { error: string | SerializedError } = await store.dispatch(thunk) if (endpointName.includes('Throw')) { expect(consoleErrorSpy).toHaveBeenCalledOnce() @@ -293,7 +291,7 @@ describe('queryFn base implementation tests', () => { { const thunk = withNeither.initiate('withNeither') - const result = (await store.dispatch(thunk)) satisfies QuerySubState + const result: QuerySubState = await store.dispatch(thunk) expect(consoleErrorSpy).toHaveBeenCalledOnce() @@ -313,10 +311,10 @@ describe('queryFn base implementation tests', () => { { const thunk = mutationWithNeither.initiate('mutationWithNeither') - const result = (await store.dispatch(thunk)) satisfies + const result: | undefined | { data: string } - | { error: string | SerializedError } + | { error: string | SerializedError } = await store.dispatch(thunk) expect(consoleErrorSpy).toHaveBeenCalledOnce() @@ -325,6 +323,10 @@ describe('queryFn base implementation tests', () => { TypeError('endpointDefinition.queryFn is not a function'), ) + if (!('error' in result)) { + expect.fail() + } + expect(result.error).toEqual( expect.objectContaining({ message: 'endpointDefinition.queryFn is not a function', @@ -419,9 +421,9 @@ describe('usage scenario tests', () => { it('can wrap a service like Firebase and handle errors', async () => { const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(noop) - const result = (await storeRef.store.dispatch( + const result: QuerySubState = await storeRef.store.dispatch( api.endpoints.getMissingFirebaseUser.initiate(1), - )) satisfies QuerySubState + ) expect(consoleErrorSpy).toHaveBeenCalledOnce()