Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to Jest 27 #693

Merged
merged 2 commits into from Jul 17, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -49,7 +49,7 @@
"is-ci": "^2.0.0",
"jest-in-case": "^1.0.2",
"jest-serializer-ansi": "^1.0.3",
"kcd-scripts": "^7.5.1",
"kcd-scripts": "^11.1.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"typescript": "^4.1.2"
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/clear.js
Expand Up @@ -89,6 +89,6 @@ test('non-inputs/textareas are currently unsupported', () => {
const {element} = setup('<div />')

expect(() => userEvent.clear(element)).toThrowErrorMatchingInlineSnapshot(
`"clear currently only supports input and textarea elements."`,
`clear currently only supports input and textarea elements.`,
)
})
1 change: 1 addition & 0 deletions src/__tests__/helpers/utils.js
@@ -1,3 +1,4 @@
/* eslint-disable testing-library/no-node-access */
import {eventMap} from '@testing-library/dom/dist/event-map'
import {isElementType} from '../../utils'
// this is pretty helpful:
Expand Down
36 changes: 18 additions & 18 deletions src/__tests__/hover.js
Expand Up @@ -70,15 +70,15 @@ test('fires non-bubbling events on parents for hover', () => {
userEvent.hover(button)

expect(calls.join('\n')).toMatchInlineSnapshot(`
"BUTTON: pointerover
DIV: pointerover
DIV: pointerenter
BUTTON: pointerenter
BUTTON: mouseover
DIV: mouseover
DIV: mouseenter
BUTTON: mouseenter"
`)
BUTTON: pointerover
DIV: pointerover
DIV: pointerenter
BUTTON: pointerenter
BUTTON: mouseover
DIV: mouseover
DIV: mouseenter
BUTTON: mouseenter
`)
})

test('fires non-bubbling events on parents for unhover', () => {
Expand Down Expand Up @@ -112,15 +112,15 @@ test('fires non-bubbling events on parents for unhover', () => {
userEvent.unhover(button)

expect(calls.join('\n')).toMatchInlineSnapshot(`
"BUTTON: pointerout
DIV: pointerout
BUTTON: pointerleave
DIV: pointerleave
BUTTON: mouseout
DIV: mouseout
BUTTON: mouseleave
DIV: mouseleave"
`)
BUTTON: pointerout
DIV: pointerout
BUTTON: pointerleave
DIV: pointerleave
BUTTON: mouseout
DIV: mouseout
BUTTON: mouseleave
DIV: mouseleave
`)
})

test('throws when hovering element with pointer-events set to none', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/paste.js
Expand Up @@ -102,7 +102,7 @@ test('should give error if we are trying to call paste on an invalid element', (
const {element} = setup('<div />')
expect(() => userEvent.paste(element, "I'm only a div :("))
.toThrowErrorMatchingInlineSnapshot(`
"The given DIV element is currently unsupported.
A PR extending this implementation would be very much welcome at https://github.com/testing-library/user-event"
The given DIV element is currently unsupported.
A PR extending this implementation would be very much welcome at https://github.com/testing-library/user-event
`)
})
1 change: 1 addition & 0 deletions src/__tests__/type.js
Expand Up @@ -232,6 +232,7 @@ test('should delay the typing when opts.delay is not 0', async () => {

const text = 'Hello, world!'
const delay = 10
// eslint-disable-next-line testing-library/no-await-sync-events
await userEvent.type(element, text, {delay})
Comment on lines +235 to 236
Copy link
Member

Choose a reason for hiding this comment

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

Is the plugin not picking up the overload anymore ? 😞

This might be just another reason for us to always return a Promise on userEvent.type in the next major.

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems like it.

I've opened testing-library/eslint-plugin-testing-library#403 so we can discuss it there. Would you still want to merge this in the meantime or would you rather wait for that to be fixed?


expect(onInput).toHaveBeenCalledTimes(text.length)
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/upload.js
Expand Up @@ -242,13 +242,13 @@ test('throw error if trying to use upload on an invalid element', () => {
expect(() =>
userEvent.upload(elements[0], "I'm only a div :("),
).toThrowErrorMatchingInlineSnapshot(
`"The given DIV element does not accept file uploads"`,
`The given DIV element does not accept file uploads`,
)

expect(() =>
userEvent.upload(elements[1], "I'm a checkbox :("),
).toThrowErrorMatchingInlineSnapshot(
`"The associated INPUT element does not accept file uploads"`,
`The associated INPUT element does not accept file uploads`,
)
})

Expand Down
1 change: 1 addition & 0 deletions src/__tests__/utils.js
@@ -1,3 +1,4 @@
/* eslint-disable testing-library/no-node-access */
import {screen} from '@testing-library/dom'
import {isElementType, isVisible} from '../utils'
import {setup} from './helpers/utils'
Expand Down