Skip to content

Commit 06eced1

Browse files
authored
Merge branch 'master' into input-file-test-fail
2 parents c167d1e + 4376e64 commit 06eced1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/__tests__/fire-event.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,15 @@ test('fireEvent.update does not crash if non-input element is passed in', async
250250
`)
251251
expect(console.warn).not.toHaveBeenCalled()
252252
})
253+
254+
test('fireEvent change/input should not throw warning when env is set', async () => {
255+
process.env.VTL_SKIP_WARN_EVENT_UPDATE = 'true'
256+
const {getByTestId} = render({
257+
template: `<input type="text" data-testid=test-input></input>`,
258+
})
259+
260+
await fireEvent.input(getByTestId('test-input'), {target: {value: 'hello'}})
261+
await fireEvent.change(getByTestId('test-input'), {target: {value: 'hello'}})
262+
263+
expect(console.warn).not.toHaveBeenCalled()
264+
})

src/vue-testing-library.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ const changeOrInputEventCalledDirectly = (eventValue, eventKey) =>
117117

118118
Object.keys(dtlFireEvent).forEach(key => {
119119
fireEvent[key] = async (...args) => {
120-
if (changeOrInputEventCalledDirectly(args[1], key)) {
120+
if (
121+
changeOrInputEventCalledDirectly(args[1], key) &&
122+
!process.env.VTL_SKIP_WARN_EVENT_UPDATE
123+
) {
121124
console.warn(
122125
`Using "fireEvent.${key} may lead to unexpected results. Please use fireEvent.update() instead.`,
123126
)

0 commit comments

Comments
 (0)