Skip to content
Open
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 @@ -41,8 +41,9 @@ const createMockErrorPersister = (
// noop
},
async restoreClient() {
await sleep(10)
throw error
return sleep(10).then(() => {
throw error
})
Comment on lines -44 to +46
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question: why? are there any functional difference ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TkDodo If we apply the pattern from #9900 (comment), we could write it like this:

return sleep(10).then(() => Promise.reject(error))

What do you think about this approach?

},
removeClient,
},
Expand Down Expand Up @@ -415,6 +416,8 @@ describe('PersistQueryClientProvider', () => {
expect(rendered.getByText('data: null')).toBeInTheDocument()
await act(() => vi.advanceTimersByTimeAsync(10))
expect(rendered.getByText('data: hydrated')).toBeInTheDocument()
await act(() => vi.advanceTimersByTimeAsync(11))
expect(rendered.getByText('data: hydrated')).toBeInTheDocument()

expect(states).toHaveLength(2)

Expand Down
Loading