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
2 changes: 1 addition & 1 deletion packages/lit-query/src/tests/infinite-and-options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ describe('createInfiniteQueryController', () => {

const nextPageResult = await infinite.fetchNextPage()
expect(nextPageResult.isFetchNextPageError).toBe(true)
expect(nextPageResult.error).toBeInstanceOf(Error)
expect(nextPageResult.error).toEqual(new Error('next-page-failed'))
await waitFor(() => infinite().isFetchNextPageError)
expect(infinite().data?.pages).toEqual([0])
})
Expand Down
6 changes: 3 additions & 3 deletions packages/lit-query/src/tests/mutation-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ describe('createMutationController', () => {
await waitFor(() => mutation().isPending)
await expect(errorPromise).rejects.toThrow('negative-not-allowed')
await waitFor(() => mutation().isError)
expect(mutation().error).toBeInstanceOf(Error)
expect(mutation().error).toEqual(new Error('negative-not-allowed'))
})

it('M10: reset clears mutation state back to idle baseline', async () => {
Expand All @@ -188,7 +188,7 @@ describe('createMutationController', () => {
'reset-target',
)
await waitFor(() => mutation().isError)
expect(mutation().error).toBeInstanceOf(Error)
expect(mutation().error).toEqual(new Error('reset-target'))

mutation.reset()
expect(mutation().isIdle).toBe(true)
Expand Down Expand Up @@ -221,7 +221,7 @@ describe('createMutationController', () => {

expect(() => mutation.mutate(-1)).not.toThrow()
await waitFor(() => mutation().isError)
expect(mutation().error).toBeInstanceOf(Error)
expect(mutation().error).toEqual(new Error('negative-not-allowed'))

await expect(mutation.mutateAsync(-1)).rejects.toThrow(
'negative-not-allowed',
Expand Down
2 changes: 1 addition & 1 deletion packages/query-core/src/__tests__/timeoutManager.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('timeoutManager', () => {
expect.stringMatching(
/\[timeoutManager\]: Switching .* might result in unexpected behavior\..*/,
),
expect.anything(),
{ previous: customProvider, provider: customProvider2 },
)

// 3. Switching again with no intermediate calls should not warn
Expand Down
2 changes: 1 addition & 1 deletion packages/query-devtools/src/__tests__/Explorer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ describe('Explorer', () => {
).toBeInTheDocument()
expect(consoleError).toHaveBeenCalledWith(
'Failed to copy: ',
expect.any(Error),
new Error('denied'),
)
})

Expand Down
8 changes: 6 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,19 @@ describe('useQueryClient', () => {
it('should throw an error when queryClient does not exist in the context', () => {
injectSpy.mockReturnValueOnce(undefined)

expect(useQueryClient).toThrow()
expect(useQueryClient).toThrow(
"No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.",
)
expect(injectSpy).toHaveBeenCalledTimes(1)
expect(injectSpy).toHaveBeenCalledWith(VUE_QUERY_CLIENT)
})

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

expect(useQueryClient).toThrow()
expect(useQueryClient).toThrow(
'vue-query hooks can only be used inside setup() function or functions that support injection context.',
)
expect(hasInjectionContextSpy).toHaveBeenCalledTimes(1)
})

Expand Down
Loading