Skip to content

Commit 09cf1e1

Browse files
committed
use jest node environment instead of mocking window object
1 parent 2a5294f commit 09cf1e1

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/tests/useQuery-SSR.test.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1+
/**
2+
* @jest-environment node
3+
*/
4+
15
import { cleanup } from '@testing-library/react'
26
import React from 'react'
37
import { renderToString } from 'react-dom/server'
8+
import { usePaginatedQuery, queryCache } from '../index'
49

510
describe('useQuery SSR', () => {
6-
beforeEach(() => {
7-
const windowSpy = jest.spyOn(global, 'window', 'get')
8-
windowSpy.mockImplementation(() => undefined)
9-
})
10-
1111
afterEach(() => {
1212
cleanup()
1313
})
1414

1515
// See https://github.com/tannerlinsley/react-query/issues/70
1616
it('should not cache queries on server', async () => {
17-
// import react-query after mocking window
18-
const { usePaginatedQuery, queryCache } = require('../index')
19-
2017
function Page() {
2118
const [page, setPage] = React.useState(1)
2219
const { resolvedData } = usePaginatedQuery(

0 commit comments

Comments
 (0)