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

Add env to turn off fireEvent.update warning #181

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/__tests__/fire-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,15 @@ test('fireEvent.update does not crash if non-input element is passed in', async
`)
expect(console.warn).not.toHaveBeenCalled()
})

test('fireEvent change/input should not throw warning when env is set', async () => {
process.env.VTL_SKIP_WARN_EVENT_UPDATE = 'true'
const {getByTestId} = render({
template: `<input type="text" data-testid=test-input></input>`,
})

await fireEvent.input(getByTestId('test-input'), {target: {value: 'hello'}})
await fireEvent.change(getByTestId('test-input'), {target: {value: 'hello'}})

expect(console.warn).not.toHaveBeenCalled()
})
5 changes: 4 additions & 1 deletion src/vue-testing-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ const changeOrInputEventCalledDirectly = (eventValue, eventKey) =>

Object.keys(dtlFireEvent).forEach(key => {
fireEvent[key] = async (...args) => {
if (changeOrInputEventCalledDirectly(args[1], key)) {
if (
changeOrInputEventCalledDirectly(args[1], key) &&
!process.env.VTL_SKIP_WARN_EVENT_UPDATE
) {
console.warn(
`Using "fireEvent.${key} may lead to unexpected results. Please use fireEvent.update() instead.`,
)
Expand Down