Skip to content

Commit c1a931d

Browse files
authored
chore: Bump kcd-scripts to 11.x (#921)
1 parent 770246e commit c1a931d

File tree

8 files changed

+59
-55
lines changed

8 files changed

+59
-55
lines changed

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@testing-library/jest-dom": "^5.11.6",
5151
"@types/react-dom": "^17.0.0",
5252
"dotenv-cli": "^4.0.0",
53-
"kcd-scripts": "^7.5.1",
53+
"kcd-scripts": "^11.1.0",
5454
"npm-run-all": "^4.1.5",
5555
"react": "^17.0.1",
5656
"react-dom": "^17.0.1",
@@ -68,7 +68,10 @@
6868
"react/no-adjacent-inline-elements": "off",
6969
"import/no-unassigned-import": "off",
7070
"import/named": "off",
71-
"testing-library/no-dom-import": "off"
71+
"testing-library/no-container": "off",
72+
"testing-library/no-dom-import": "off",
73+
"testing-library/no-unnecessary-act": "off",
74+
"testing-library/prefer-user-event": "off"
7275
}
7376
},
7477
"eslintIgnore": [

src/__tests__/cleanup.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,16 @@ describe('fake timers and missing act warnings', () => {
5454
jest.useRealTimers()
5555
})
5656

57-
test('cleanup does not flush immediates', () => {
57+
test('cleanup does not flush microtasks', () => {
5858
const microTaskSpy = jest.fn()
5959
function Test() {
6060
const counter = 1
6161
const [, setDeferredCounter] = React.useState(null)
6262
React.useEffect(() => {
6363
let cancelled = false
64-
setImmediate(() => {
64+
Promise.resolve().then(() => {
6565
microTaskSpy()
66+
// eslint-disable-next-line jest/no-if -- false positive
6667
if (!cancelled) {
6768
setDeferredCounter(counter)
6869
}
@@ -92,12 +93,12 @@ describe('fake timers and missing act warnings', () => {
9293
const [, setDeferredCounter] = React.useState(null)
9394
React.useEffect(() => {
9495
let cancelled = false
95-
setImmediate(() => {
96+
setTimeout(() => {
9697
deferredStateUpdateSpy()
9798
if (!cancelled) {
9899
setDeferredCounter(counter)
99100
}
100-
})
101+
}, 0)
101102

102103
return () => {
103104
cancelled = true
@@ -108,7 +109,7 @@ describe('fake timers and missing act warnings', () => {
108109
}
109110
render(<Test />)
110111

111-
jest.runAllImmediates()
112+
jest.runAllTimers()
112113
cleanup()
113114

114115
expect(deferredStateUpdateSpy).toHaveBeenCalledTimes(1)

src/__tests__/debug.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ test('allows same arguments as prettyDOM', () => {
4343
expect(console.log).toHaveBeenCalledTimes(1)
4444
expect(console.log.mock.calls[0]).toMatchInlineSnapshot(`
4545
Array [
46-
"<div>
47-
...",
46+
<div>
47+
...,
4848
]
4949
`)
5050
})

src/__tests__/new-act.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test('async act recovers from errors', async () => {
4949
expect(console.error.mock.calls).toMatchInlineSnapshot(`
5050
Array [
5151
Array [
52-
"call console.error",
52+
call console.error,
5353
],
5454
]
5555
`)
@@ -67,7 +67,7 @@ test('async act recovers from sync errors', async () => {
6767
expect(console.error.mock.calls).toMatchInlineSnapshot(`
6868
Array [
6969
Array [
70-
"call console.error",
70+
call console.error,
7171
],
7272
]
7373
`)

src/__tests__/no-act.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ let act, asyncAct
22

33
beforeEach(() => {
44
jest.resetModules()
5-
act = require('..').act
5+
act = require('../pure').act
66
asyncAct = require('../act-compat').asyncAct
77
jest.spyOn(console, 'error').mockImplementation(() => {})
88
})
@@ -53,7 +53,7 @@ test('async act recovers from errors', async () => {
5353
expect(console.error.mock.calls).toMatchInlineSnapshot(`
5454
Array [
5555
Array [
56-
"call console.error",
56+
call console.error,
5757
],
5858
]
5959
`)
@@ -71,7 +71,7 @@ test('async act recovers from sync errors', async () => {
7171
expect(console.error.mock.calls).toMatchInlineSnapshot(`
7272
Array [
7373
Array [
74-
"call console.error",
74+
call console.error,
7575
],
7676
]
7777
`)

src/__tests__/old-act.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ test('async act works even when the act is an old one', async () => {
3232
console.error('sigil')
3333
})
3434
expect(console.error.mock.calls).toMatchInlineSnapshot(`
35-
Array [
36-
Array [
37-
"sigil",
38-
],
39-
Array [
40-
"It looks like you're using a version of react-dom that supports the \\"act\\" function, but not an awaitable version of \\"act\\" which you will need. Please upgrade to at least [email protected] to remove this warning.",
41-
],
42-
Array [
43-
"sigil",
44-
],
45-
]
46-
`)
35+
Array [
36+
Array [
37+
sigil,
38+
],
39+
Array [
40+
It looks like you're using a version of react-dom that supports the "act" function, but not an awaitable version of "act" which you will need. Please upgrade to at least [email protected] to remove this warning.,
41+
],
42+
Array [
43+
sigil,
44+
],
45+
]
46+
`)
4747
expect(callback).toHaveBeenCalledTimes(1)
4848

4949
// and it doesn't warn you twice
@@ -71,10 +71,10 @@ test('async act recovers from async errors', async () => {
7171
expect(console.error.mock.calls).toMatchInlineSnapshot(`
7272
Array [
7373
Array [
74-
"It looks like you're using a version of react-dom that supports the \\"act\\" function, but not an awaitable version of \\"act\\" which you will need. Please upgrade to at least [email protected] to remove this warning.",
74+
It looks like you're using a version of react-dom that supports the "act" function, but not an awaitable version of "act" which you will need. Please upgrade to at least [email protected] to remove this warning.,
7575
],
7676
Array [
77-
"call console.error",
77+
call console.error,
7878
],
7979
]
8080
`)
@@ -92,7 +92,7 @@ test('async act recovers from sync errors', async () => {
9292
expect(console.error.mock.calls).toMatchInlineSnapshot(`
9393
Array [
9494
Array [
95-
"call console.error",
95+
call console.error,
9696
],
9797
]
9898
`)
@@ -109,11 +109,11 @@ test('async act can handle any sort of console.error', async () => {
109109
Array [
110110
Array [
111111
Object {
112-
"error": "some error",
112+
error: some error,
113113
},
114114
],
115115
Array [
116-
"It looks like you're using a version of react-dom that supports the \\"act\\" function, but not an awaitable version of \\"act\\" which you will need. Please upgrade to at least [email protected] to remove this warning.",
116+
It looks like you're using a version of react-dom that supports the "act" function, but not an awaitable version of "act" which you will need. Please upgrade to at least [email protected] to remove this warning.,
117117
],
118118
]
119119
`)

src/__tests__/render.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ test('renders options.wrapper around node', () => {
7878

7979
expect(screen.getByTestId('wrapper')).toBeInTheDocument()
8080
expect(container.firstChild).toMatchInlineSnapshot(`
81-
<div
82-
data-testid="wrapper"
83-
>
84-
<div
85-
data-testid="inner"
86-
/>
87-
</div>
88-
`)
81+
<div
82+
data-testid=wrapper
83+
>
84+
<div
85+
data-testid=inner
86+
/>
87+
</div>
88+
`)
8989
})
9090

9191
test('flushes useEffect cleanup functions sync on unmount()', () => {

types/test.tsx

+16-16
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,39 @@ import {render, fireEvent, screen, waitFor} from '.'
33
import * as pure from './pure'
44

55
export async function testRender() {
6-
const page = render(<button />)
6+
const view = render(<button />)
77

88
// single queries
9-
page.getByText('foo')
10-
page.queryByText('foo')
11-
await page.findByText('foo')
9+
view.getByText('foo')
10+
view.queryByText('foo')
11+
await view.findByText('foo')
1212

1313
// multiple queries
14-
page.getAllByText('bar')
15-
page.queryAllByText('bar')
16-
await page.findAllByText('bar')
14+
view.getAllByText('bar')
15+
view.queryAllByText('bar')
16+
await view.findAllByText('bar')
1717

1818
// helpers
19-
const {container, rerender, debug} = page
19+
const {container, rerender, debug} = view
2020
expectType<HTMLElement, typeof container>(container)
2121
return {container, rerender, debug}
2222
}
2323

2424
export async function testPureRender() {
25-
const page = pure.render(<button />)
25+
const view = pure.render(<button />)
2626

2727
// single queries
28-
page.getByText('foo')
29-
page.queryByText('foo')
30-
await page.findByText('foo')
28+
view.getByText('foo')
29+
view.queryByText('foo')
30+
await view.findByText('foo')
3131

3232
// multiple queries
33-
page.getAllByText('bar')
34-
page.queryAllByText('bar')
35-
await page.findAllByText('bar')
33+
view.getAllByText('bar')
34+
view.queryAllByText('bar')
35+
await view.findAllByText('bar')
3636

3737
// helpers
38-
const {container, rerender, debug} = page
38+
const {container, rerender, debug} = view
3939
expectType<HTMLElement, typeof container>(container)
4040
return {container, rerender, debug}
4141
}

0 commit comments

Comments
 (0)