diff --git a/README.md b/README.md index 872bd601..ebe299b3 100644 --- a/README.md +++ b/README.md @@ -266,6 +266,6 @@ instead of filing an issue on GitHub. [vuex-example]: https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__/vuex.js [vue-router-example]: https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__/vue-router.js [vee-validate-example]: https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__/validate-plugin.js -[vue-i18n-example]: https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__/vueI18n.js +[vue-i18n-example]: https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__/vue-i18n.js [vuetify-example]: https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__/vuetify.js diff --git a/src/__tests__/components/Translations.vue b/src/__tests__/components/Translations.vue index 0510b5d8..328ee70d 100644 --- a/src/__tests__/components/Translations.vue +++ b/src/__tests__/components/Translations.vue @@ -8,7 +8,7 @@ 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/__tests__/vueI18n.js b/src/__tests__/vueI18n.js deleted file mode 100644 index d61545ac..00000000 --- a/src/__tests__/vueI18n.js +++ /dev/null @@ -1,38 +0,0 @@ -import '@testing-library/jest-dom' -import {render, fireEvent} from '@testing-library/vue' -import Vuei18n from 'vue-i18n' -import VueI18n from './components/VueI18n' - -const messages = { - en: { - Hello: 'Hello', - }, - ja: { - Hello: 'こんにちは', - }, -} - -test('renders translations', async () => { - const {queryByText, getByText} = render(VueI18n, {}, vue => { - // Let's register Vuei18n normally - vue.use(Vuei18n) - - const i18n = new Vuei18n({ - locale: 'en', - fallbackLocale: 'en', - messages, - }) - - // Notice how we return an object from the callback function. It will be - // available as an additional option on the created Vue instance. - return {i18n} - }) - - expect(getByText('Hello')).toBeInTheDocument() - - await fireEvent.click(getByText('Japanese')) - - expect(getByText('こんにちは')).toBeInTheDocument() - - expect(queryByText('Hello')).toBeNull() -}) 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.`, )