diff --git a/src/__tests__/fire-event.js b/src/__tests__/fire-event.js index 221ca549..668ca551 100644 --- a/src/__tests__/fire-event.js +++ b/src/__tests__/fire-event.js @@ -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: ``, + }) + + await fireEvent.input(getByTestId('test-input'), {target: {value: 'hello'}}) + await fireEvent.change(getByTestId('test-input'), {target: {value: 'hello'}}) + + expect(console.warn).not.toHaveBeenCalled() +}) diff --git a/src/vue-testing-library.js b/src/vue-testing-library.js index def669ed..89dcdc04 100644 --- a/src/vue-testing-library.js +++ b/src/vue-testing-library.js @@ -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.`, )