2017-09-13 64 views
0

運行我的單元測試,即使我已經在我的Chrome瀏覽器中添加了Devtools擴展,我總是收到這些信息消息?Vues.js單元測試w Karma-Mocha-HeadlessChrome,爲什麼要關於Vue Devtools的消息INFO?

yves$ npm run unit 
> [email protected] unit /Users/yves/Developments//shopping-list 
> cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run 

[karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/ 
launcher]: Launching browser ChromeHeadless with unlimited concurrency 
[launcher]: Starting browser ChromeHeadless 
HeadlessChrome 0.0.0 (Mac OS X 10.12.6)]: Connected on socket s3ED3TVFNjuvVojoAAAA with id 22013100 

INFO LOG: 'Download the Vue Devtools extension for a better development experience: 
https://github.com/vuejs/vue-devtools' 

我找到一種方法來擺脫它,在我actions.spec.js插入下面的代碼:

import Vue from 'vue' 
const isHeadlessChrome = /\bHeadlessChrome\//.test(navigator.userAgent) 
Vue.config.devtools = !isHeadlessChrome 
Vue.config.productionTip = false 

,但有什麼辦法來運行它之前所有的單元測試?

回答

0

在karma.conf.js文件,預處理器指示:

預處理器:{ './index.js ':[' 的WebPack', 'sourcemap'] },

所以我將acn插入test/unit/index.js內的一段代碼

import Vue from 'vue' 

const isHeadlessChrome = /\bHeadlessChrome\//.test(navigator.userAgent) 
Vue.config.devtools = !isHeadlessChrome 
Vue.config.productionTip = false