Skip to content
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