Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('injectInfiniteQuery', () => {
initialPageParam: 0,
getNextPageParam: () => 12,
}))
}).toThrowError(/NG0203(.*?)injectInfiniteQuery/)
}).toThrow(/NG0203(.*?)injectInfiniteQuery/)
})

test('can be used outside injection context when passing an injector', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('injectIsFetching', () => {
test('throws NG0203 with descriptive error outside injection context', () => {
expect(() => {
injectIsFetching()
}).toThrowError(/NG0203(.*?)injectIsFetching/)
}).toThrow(/NG0203(.*?)injectIsFetching/)
})

test('can be used outside injection context when passing an injector', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('injectIsMutating', () => {
test('throws NG0203 with descriptive error outside injection context', () => {
expect(() => {
injectIsMutating()
}).toThrowError(/NG0203(.*?)injectIsMutating/)
}).toThrow(/NG0203(.*?)injectIsMutating/)
})

test('can be used outside injection context when passing an injector', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ describe('injectIsRestoring', () => {
test('throws NG0203 with descriptive error outside injection context', () => {
expect(() => {
injectIsRestoring()
}).toThrowError(/NG0203(.*?)injectIsRestoring/)
}).toThrow(/NG0203(.*?)injectIsRestoring/)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe('injectMutationState', () => {
test('throws NG0203 with descriptive error outside injection context', () => {
expect(() => {
injectMutationState()
}).toThrowError(/NG0203(.*?)injectMutationState/)
}).toThrow(/NG0203(.*?)injectMutationState/)
})

test('can be used outside injection context when passing an injector', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ describe('injectMutation', () => {
}))
})

await expect(() => mutateAsync()).rejects.toThrowError(err)
await expect(() => mutateAsync()).rejects.toThrow(err)
})

test('should throw when throwOnError function returns true', async () => {
Expand All @@ -463,7 +463,7 @@ describe('injectMutation', () => {
}))
})

await expect(() => mutateAsync()).rejects.toThrowError(err)
await expect(() => mutateAsync()).rejects.toThrow(err)
})

describe('injection context', () => {
Expand All @@ -473,7 +473,7 @@ describe('injectMutation', () => {
mutationKey: ['injectionContextError'],
mutationFn: () => Promise.resolve(),
}))
}).toThrowError(/NG0203(.*?)injectMutation/)
}).toThrow(/NG0203(.*?)injectMutation/)
})

test('can be used outside injection context when passing an injector', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ describe('injectQuery', () => {
queryKey: ['injectionContextError'],
queryFn: () => sleep(0).then(() => 'Some data'),
}))
}).toThrowError(/NG0203(.*?)injectQuery/)
}).toThrow(/NG0203(.*?)injectQuery/)
})

test('can be used outside injection context when passing an injector', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,6 @@ describe('asyncThrottle', () => {
})

test('should throw error when "func" is not a function', () => {
expect(() => asyncThrottle(1 as any)).toThrowError()
expect(() => asyncThrottle(1 as any)).toThrow()
})
})
2 changes: 1 addition & 1 deletion packages/query-core/src/__tests__/queryObserver.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ describe('queryObserver', () => {
// @ts-expect-error
enabled: null,
}),
).toThrowError('Expected enabled to be a boolean')
).toThrow('Expected enabled to be a boolean')
})

test('getCurrentQuery should return the current query', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte-query/tests/context/context.svelte.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import BaseExample from './BaseExample.svelte'

describe('getQueryClientContext', () => {
test('Throw when called without a client in context', () => {
expect(() => render(BaseExample)).toThrowError(
expect(() => render(BaseExample)).toThrow(
'No QueryClient was found in Svelte context. Did you forget to wrap your component with QueryClientProvider?',
)
})
})

describe('getIsRestoringContext', () => {
test('Do not throw when called outside of a component', () => {
expect(() => getIsRestoringContext()).not.toThrowError()
expect(() => getIsRestoringContext()).not.toThrow()
})
})
2 changes: 1 addition & 1 deletion packages/vue-query/src/__tests__/useMutation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ describe('useMutation', () => {
})

await vi.waitFor(() =>
expect(mutation.mutateAsync()).rejects.toThrowError('Some error'),
expect(mutation.mutateAsync()).rejects.toThrow('Some error'),
)

expect(mutation).toMatchObject({
Expand Down
4 changes: 2 additions & 2 deletions packages/vue-query/src/__tests__/useQueryClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ describe('useQueryClient', () => {
test('should throw an error when queryClient does not exist in the context', () => {
injectSpy.mockReturnValueOnce(undefined)

expect(useQueryClient).toThrowError()
expect(useQueryClient).toThrow()
expect(injectSpy).toHaveBeenCalledTimes(1)
expect(injectSpy).toHaveBeenCalledWith(VUE_QUERY_CLIENT)
})

test('should throw an error when used outside of setup function', () => {
hasInjectionContextSpy.mockReturnValueOnce(false)

expect(useQueryClient).toThrowError()
expect(useQueryClient).toThrow()
expect(hasInjectionContextSpy).toHaveBeenCalledTimes(1)
})

Expand Down
Loading