我理解你的jest.设置.js代码,你应该设置
Vue.config.productionTip = false;
Vue.config.devtools = false;
我也是.事实上,这是我的Jest .设置.js代码.注意控制台.日志(log)("yo-ho");
// test/setup.js
import Vue from 'vue';
import Vuetify from 'vuetify';
import { config } from '@vue/test-utils';
import VueCompositionApi from '@vue/composition-api'; // <-- Make the import
Vue.use(Vuetify);
Vue.use(VueCompositionApi);
Vue.config.productionTip = false;
Vue.config.devtools = false;
console.log('yo ho');
// https://vue-test-utils.vuejs.org/
// and this came from: https://github.com/kazupon/vue-i18n/issues/323
// it mocks out the $t function to return the key so you can test that the right key is being used
config.mocks = {
$t: (key) => 'i18n:' + key
};
因此,考虑到这一点,我预计永远不会收到这些警告.但我在大约1/3的单元测试文件上做了.不是我所有的单元测试文件,只是其中的一些.我真的很困惑.
然后我添加了控制台日志(log)语句,以确保在单元测试中我得到了这个警告,即Jest .设置.js实际上正在被呼叫.这是我的一个单元测试的输出:
PASS src/components/announcement-banner.test.ts (8.255s)
● Console
console.log tests/unit/jest.setup.js:12
yo ho
console.info node_modules/Vue/dist/vue.runtime.common.dev.js:8403
Download the Vue Devtools extension for a better development experience:
https://github.com/vuejs/vue-devtools
console.info node_modules/Vue/dist/vue.runtime.common.dev.js:8412
You are running Vue in development mode.
Make sure to turn on production mode when deploying for production.
See more tips at https://vuejs.org/guide/deployment.html
我到底是怎么得到Vue警告的,而我肯定是在Jest .设置?
为了消除这些警告,我必须转到特定的测试文件,并在createLocalVue()调用之前直接添加配置行.
Vue.config.productionTip = false;
Vue.config.devtools = false;
const localVue = createLocalVue();