Skip to content

Commit 4028455

Browse files
committed
avoid use snapshot
1 parent ba01a07 commit 4028455

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

src/tests/suspense.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { render, waitForElement, fireEvent, cleanup } from '@testing-library/react'
1+
import {
2+
render,
3+
waitForElement,
4+
fireEvent,
5+
cleanup,
6+
} from '@testing-library/react'
27
import * as React from 'react'
38

49
import { useQuery, ReactQueryCacheProvider, queryCache } from '../index'

src/tests/useQuery.test.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { render, act, waitForElement, fireEvent, cleanup, waitForDomChange } from '@testing-library/react'
1+
import {
2+
render,
3+
act,
4+
waitForElement,
5+
fireEvent,
6+
cleanup,
7+
waitForDomChange,
8+
} from '@testing-library/react'
29
import { ErrorBoundary } from 'react-error-boundary'
310
import * as React from 'react'
411

@@ -1013,56 +1020,56 @@ describe('useQuery', () => {
10131020
)
10141021
}
10151022
const { container } = render(<Page />)
1016-
expect(container.firstChild.textContent).toMatchInlineSnapshot(`"count: "`)
1017-
1023+
expect(container.firstChild.textContent).toEqual('count: ')
1024+
console.log(container.firstChild.textContent)
10181025
await waitForDomChange({ container }) // mount
1019-
expect(container.firstChild.textContent).toMatchInlineSnapshot(`"count: 0"`)
1026+
expect(container.firstChild.textContent).toEqual('count: 0')
10201027
await act(() => {
10211028
return new Promise(res => setTimeout(res, 210))
10221029
})
1023-
expect(container.firstChild.textContent).toMatchInlineSnapshot(`"count: 1"`)
1030+
expect(container.firstChild.textContent).toEqual('count: 1')
10241031
await act(() => {
10251032
return new Promise(res => setTimeout(res, 50))
10261033
})
1027-
expect(container.firstChild.textContent).toMatchInlineSnapshot(`"count: 1"`)
1034+
expect(container.firstChild.textContent).toEqual('count: 1')
10281035
await act(() => {
10291036
return new Promise(res => setTimeout(res, 150))
10301037
})
1031-
expect(container.firstChild.textContent).toMatchInlineSnapshot(`"count: 2"`)
1038+
expect(container.firstChild.textContent).toEqual('count: 2')
10321039
await act(() => {
10331040
fireEvent.click(container.firstElementChild)
10341041
// it will clear 200ms timer and setup a new 300ms timer
10351042
return new Promise(res => setTimeout(res, 200))
10361043
})
1037-
expect(container.firstChild.textContent).toMatchInlineSnapshot(`"count: 2"`)
1044+
expect(container.firstChild.textContent).toEqual('count: 2')
10381045
await act(() => {
10391046
return new Promise(res => setTimeout(res, 110))
10401047
})
1041-
expect(container.firstChild.textContent).toMatchInlineSnapshot(`"count: 3"`)
1048+
expect(container.firstChild.textContent).toEqual('count: 3')
10421049
await act(() => {
10431050
// wait for new 300ms timer
10441051
return new Promise(res => setTimeout(res, 310))
10451052
})
1046-
expect(container.firstChild.textContent).toMatchInlineSnapshot(`"count: 4"`)
1053+
expect(container.firstChild.textContent).toEqual('count: 4')
10471054
await act(() => {
10481055
fireEvent.click(container.firstElementChild)
10491056
// it will clear 300ms timer and setup a new 400ms timer
10501057
return new Promise(res => setTimeout(res, 300))
10511058
})
1052-
expect(container.firstChild.textContent).toMatchInlineSnapshot(`"count: 4"`)
1059+
expect(container.firstChild.textContent).toEqual('count: 4')
10531060
await act(() => {
10541061
return new Promise(res => setTimeout(res, 110))
10551062
})
1056-
expect(container.firstChild.textContent).toMatchInlineSnapshot(`"count: 5"`)
1063+
expect(container.firstChild.textContent).toEqual('count: 5')
10571064
await act(() => {
10581065
fireEvent.click(container.firstElementChild)
10591066
// it will clear 400ms timer and stop
10601067
return new Promise(res => setTimeout(res, 110))
10611068
})
1062-
expect(container.firstChild.textContent).toMatchInlineSnapshot(`"count: 5"`)
1069+
expect(container.firstChild.textContent).toEqual('count: 5')
10631070
await act(() => {
10641071
return new Promise(res => setTimeout(res, 110))
10651072
})
1066-
expect(container.firstChild.textContent).toMatchInlineSnapshot(`"count: 5"`)
1073+
expect(container.firstChild.textContent).toEqual('count: 5')
10671074
})
10681075
})

0 commit comments

Comments
 (0)