Open mkapiczy opened 5 years ago
I'm also getting these error messages. Please note https://github.com/vuejs/vue-cli/issues/1363#issuecomment-440766916.
@mkapiczy was babel 7 the only thing you upgraded?
Encountered this error today and couldn't configure my way out of it for the life of me. I later discovered Webpack had been misconfigured to run the instrumenter task twice. Configuring it to run once eliminated the error.
So, check your webpack test runner configuration. Even if you configured the instrumenter yourself, you may have obscure code that does the same thing automatically!
Hi @mkapiczy , can you try to remove the "istanbul"
from .babelrc
and add istambul-instrumenter-loader
back to your loader.
Both babel-plugin and webpack-loader will run the instrumenter task. As you can see, the output will be
ee.exit(path); // undefined
once program exit (actually, I don't know what program is it)
For me, I choose remove the babel-plugin-istanbul
and setting istambul-instrumenter-loader
in the wbpack configuration.
Update
You should use babel-plugin-istanbul
if you faced TypeError: Cannot read property 'text' of undefined
and setting include / exclude in the .babelrc
, for more infor please refer https://github.com/gotwarlost/istanbul/issues/602#issuecomment-356062165
This seems almost always caused by an already instrumented code -- the only way the undefined
value would appear from is:
@iamahuman @woram-nyansa you say the cause but not the solution, can you please help me finding the solution?
Here is my configs:
vue.config.js
module.exports = {
devServer: {
port: process.env.VUE_APP_PORT,
allowedHosts: [process.env.VUE_APP_HOST]
},
chainWebpack: config => {
const svgRule = config.module.rule('svg')
svgRule.uses.clear()
svgRule.use('vue-svg-loader').loader('vue-svg-loader')
config.output.globalObject('this')
if (process.env.NODE_ENV === 'test') {
// To debug using vscode
config.devtool = '#inline-cheap-module-source-map'
const path = require('path')
config.module
.rule('istanbul')
.test(/\.(ts|vue)$/)
.enforce('post')
.include.add(path.resolve(__dirname, 'src'))
.end()
.use('istanbul-instrumenter-loader')
.loader('istanbul-instrumenter-loader')
.options({ esModules: true })
}
}
}
babel.config.js
module.exports = {
presets: [
[
'@vue/app',
{
useBuiltIns: 'entry'
}
]
],
plugins: [
[
'transform-imports',
{
vuetify: {
transform: 'vuetify/es5/components/${member}', // eslint-disable-line no-template-curly-in-string
preventFullImport: true
}
}
]
],
env: {
test: {
presets: ['@babel/preset-env'],
plugins: ['istanbul']
}
}
}
package.json
...
"dependencies": {
"@babel/polyfill": "^7.0.0-rc.1",
"@casl/ability": "^3.0.1",
"@casl/vue": "^0.5.1",
"@fullcalendar/core": "^4.2.0",
"@fullcalendar/daygrid": "^4.1.0",
"@fullcalendar/list": "^4.1.0",
"@fullcalendar/timegrid": "^4.1.0",
"@fullcalendar/vue": "^4.1.0",
"@tinymce/tinymce-vue": "^1.1.0",
"@types/lodash": "^4.14.120",
"@types/moment-timezone": "^0.5.10",
"@types/rosie": "0.0.36",
"@types/sinon": "^7.0.5",
"actioncable-vue": "^1.2.4",
"aws-sdk": "^2.336.0",
"dotenv": "^6.1.0",
"element-ui": "2.9.2",
"filesize": "^4.0.0",
"flush-promises": "^1.0.2",
"jwt-decode": "^2.2.0",
"material-design-icons-iconfont": "^3.0.3",
"moment": "^2.22.2",
"moment-timezone": "^0.5.23",
"roboto-fontface": "*",
"rosie": "^2.0.1",
"rut-helpers": "^0.1.1",
"s3-easy-deploy": "^1.1.0",
"tinycolor2": "^1.4.1",
"v-calendar": "^1.0.0-beta.14",
"v-click-outside": "^2.1.1",
"v-money": "^0.8.1",
"vue": "^2.5.21",
"vue-class-component": "^6.3.2",
"vue-clickaway": "^2.2.2",
"vue-full-loading": "^1.2.1",
"vue-i18n": "^8.7.0",
"vue-lodash": "^2.0.0",
"vue-mixin-decorator": "^1.1.0",
"vue-moment": "^4.0.0",
"vue-pdf": "arioth/vue-pdf#253f6186ff0676abf9277786087dda8d95dd8ea7",
"vue-property-decorator": "^7.3.0",
"vue-resource": "^1.5.1",
"vue-router": "^3.0.1",
"vue-svgicon": "^3.2.2",
"vue-tel-input": "^2.0.13",
"vue-wait": "arioth/vue-wait#b6cabe208f3d552fb62bc69621d60dda755bb643",
"vuedraggable": "^2.20.0",
"vuex": "^3.0.1",
"vuex-class": "^0.3.1",
"vuex-persistedstate": "^2.5.4"
},
"devDependencies": {
"@babel/core": "^7.3.3",
"@babel/preset-env": "^7.0.0",
"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.4",
"@vue/cli-plugin-babel": "^3.4.1",
"@vue/cli-plugin-e2e-nightwatch": "^3.8.0",
"@vue/cli-plugin-eslint": "^3.0.1",
"@vue/cli-plugin-typescript": "^3.6.0",
"@vue/cli-plugin-unit-mocha": "^3.0.1",
"@vue/cli-service": "^3.6.0",
"@vue/eslint-config-typescript": "^3.0.1",
"babel-loader": "^8.0.2",
"babel-plugin-istanbul": "^5.1.4",
"babel-plugin-transform-imports": "^1.5.0",
"chai": "^4.2.0",
"electron": "^4.0.2",
"eslint": "^5.10.0",
"eslint-plugin-vue": "^5.0.0",
"istanbul-instrumenter-loader": "^3.0.1",
"jsdom": "^13.2.0",
"jsdom-global": "^3.0.2",
"node-sass": "^4.11.0",
"nyc": "^14.1.1",
"pug": "^2.0.3",
"pug-plain-loader": "^1.0.0",
"sass-loader": "^7.0.1",
"sinon": "^7.2.3",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.1",
"typescript": "~3.1.1",
"vue-svg-loader": "^0.11.0",
"vue-template-compiler": "^2.5.21",
"webpack": "^4.17.2"
},
"nyc": {
"check-coverage": true,
"per-file": true,
"lines": 90,
"statements": 90,
"functions": 90,
"branches": 90,
"include": [
"src/**/*.{ts,vue}"
],
"reporter": [
"lcov",
"text-summary"
],
"extension": [
".ts",
".vue"
],
"cache": true,
"all": true
}
@silva96 This is not necessarily istanbul-instrumenter-loader's fault, and in my case it was due to an issue in vue-loader pitcher's loader request injection which managed to come to the surface via an edge case introduced by throwing both TypeScript loader and Vue SFC loader into the mix, but it wasn't pretty easy to come up with a clean solution and then soon after a while I forgot about it.
@silva96 In your case, you might have some luck by taking out either one of the following lines in your vue.config.js
:
.use('istanbul-instrumenter-loader')
.loader('istanbul-instrumenter-loader')
Back to on-topic discussion, a solution for this issue would be to notify user of the duplicated instrumentation instead of the unhelpful message, since ignoring it would highly likely introduce yet another obscure bug which might be even harder to trace.
Since it is clear that this issue is solely caused by instrumenting already instrumented code I'd like to suggest type: Bug, priority: 5 (nice to have), severity: 5 (confusing)
.
@iamahuman
@silva96 In your case, you might have some luck by taking out either one of the following lines in your
vue.config.js
:.use('istanbul-instrumenter-loader') .loader('istanbul-instrumenter-loader')
That didn't work
Taking .loader('istanbul-instrumenter-loader')
out:
nyc vue-cli-service test:unit --require ./tests/unit/setup.js --timeout 10000
Error: No loader specified
at Function.normalizeUseItem (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/RuleSet.js:389:10)
at Function.normalizeUse (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/RuleSet.js:360:19)
at use.map (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/RuleSet.js:357:33)
at Array.map (<anonymous>)
at Function.normalizeUse (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/RuleSet.js:357:6)
at Function.normalizeRule (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/RuleSet.js:288:26)
at rules.map (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/RuleSet.js:110:20)
at Array.map (<anonymous>)
at Function.normalizeRules (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/RuleSet.js:109:17)
at new RuleSet (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/RuleSet.js:104:24)
at VueLoaderPlugin.apply (/Users/benja/dev/ventanilla-front/node_modules/vue-loader/lib/plugin.js:35:23)
at webpack (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/webpack.js:37:12)
at createCompiler (/Users/benja/dev/ventanilla-front/node_modules/mocha-webpack/lib/webpack/compiler/createCompiler.js:15:40)
at TestRunner.<anonymous> (/Users/benja/dev/ventanilla-front/node_modules/mocha-webpack/lib/runner/TestRunner.js:166:51)
at eval (eval at processIncludes (/Users/benja/dev/ventanilla-front/node_modules/nodent-runtime/runtime.js:36:12), <anonymous>:3:4725)
ERROR mocha-webpack exited with code 1.
=============================== Coverage summary ===============================
Statements : Unknown% ( 0/0 )
Branches : Unknown% ( 0/0 )
Functions : Unknown% ( 0/0 )
Lines : Unknown% ( 0/0 )
================================================================================
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ventas-frontend@0.1.0 test:unit: `nyc vue-cli-service test:unit --require ./tests/unit/setup.js --timeout 10000`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ventas-frontend@0.1.0 test:unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/benja/.npm/_logs/2019-06-24T16_20_43_535Z-debug.log
Taking .use('istanbul-instrumenter-loader')
out
nyc vue-cli-service test:unit --require ./tests/unit/setup.js --timeout 10000
/Users/benja/dev/ventanilla-front/vue.config.js:23
.loader('istanbul-instrumenter-loader')
^
TypeError: config.module.rule(...).test(...).enforce(...).include.add(...).end(...).loader is not a function
at chainWebpack (/Users/benja/dev/ventanilla-front/vue.config.js:23:10)
at webpackChainFns.forEach.fn (/Users/benja/dev/ventanilla-front/node_modules/@vue/cli-service/lib/Service.js:227:40)
at Array.forEach (<anonymous>)
at Service.resolveChainableWebpackConfig (/Users/benja/dev/ventanilla-front/node_modules/@vue/cli-service/lib/Service.js:227:26)
at Service.resolveWebpackConfig (/Users/benja/dev/ventanilla-front/node_modules/@vue/cli-service/lib/Service.js:231:48)
at Object.<anonymous> (/Users/benja/dev/ventanilla-front/node_modules/@vue/cli-service/webpack.config.js:12:26)
at Module._compile (internal/modules/cjs/loader.js:723:30)
at Module.replacementCompile (/Users/benja/dev/ventanilla-front/node_modules/append-transform/index.js:58:13)
at Module._extensions..js (internal/modules/cjs/loader.js:734:10)
at Object.<anonymous> (/Users/benja/dev/ventanilla-front/node_modules/append-transform/index.js:62:4)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Module.require (internal/modules/cjs/loader.js:659:17)
at require (internal/modules/cjs/helpers.js:22:18)
at requireWebpackConfig (/Users/benja/dev/ventanilla-front/node_modules/mocha-webpack/lib/cli/requireWebpackConfig.js:99:14)
ERROR mocha-webpack exited with code 1.
=============================== Coverage summary ===============================
Statements : Unknown% ( 0/0 )
Branches : Unknown% ( 0/0 )
Functions : Unknown% ( 0/0 )
Lines : Unknown% ( 0/0 )
================================================================================
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ventas-frontend@0.1.0 test:unit: `nyc vue-cli-service test:unit --require ./tests/unit/setup.js --timeout 10000`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ventas-frontend@0.1.0 test:unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/benja/.npm/_logs/2019-06-24T16_22_05_206Z-debug.log
Taking both out:
MOCHA Testing...
RUNTIME EXCEPTION Exception occurred while loading your tests
TypeError: Cannot read property 'f' of undefined
at Module.getTimezones (/Users/benja/dev/ventanilla-front/dist/webpack:/src/utils/functions.ts:62:1)
at Module../src/store/modules/settings/getters.ts (/Users/benja/dev/ventanilla-front/dist/webpack:/src/store/modules/settings/getters.ts:35:1)
at __webpack_require__ (/Users/benja/dev/ventanilla-front/dist/webpack:/webpack/bootstrap:25:1)
at Module../src/store/modules/settings/index.ts (/Users/benja/dev/ventanilla-front/dist/main.js:388129:66)
at __webpack_require__ (/Users/benja/dev/ventanilla-front/dist/webpack:/webpack/bootstrap:25:1)
at Module../src/store/index.ts (/Users/benja/dev/ventanilla-front/dist/main.js:351856:75)
at __webpack_require__ (/Users/benja/dev/ventanilla-front/dist/webpack:/webpack/bootstrap:25:1)
at Module../src/utils/functions.ts (/Users/benja/dev/ventanilla-front/dist/main.js:397749:64)
at __webpack_require__ (/Users/benja/dev/ventanilla-front/dist/webpack:/webpack/bootstrap:25:1)
at Module../node_modules/cache-loader/dist/cjs.js?!./node_modules/@vue/cli-plugin-babel/node_modules/babel-loader/lib/index.js!./node_modules/ts-loader/index.js?!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/inputs/types/SeatSelectInput.vue?vue&type=script&lang=ts& (/Users/benja/dev/ventanilla-front/dist/main.js:40141:74)
at __webpack_require__ (/Users/benja/dev/ventanilla-front/dist/webpack:/webpack/bootstrap:25:1)
at Module../src/components/inputs/types/SeatSelectInput.vue?vue&type=script&lang=ts& (/Users/benja/dev/ventanilla-front/dist/webpack:/src/components/inputs/types/SeatSelectInput.vue?c6eb:1:1)
at __webpack_require__ (/Users/benja/dev/ventanilla-front/dist/webpack:/webpack/bootstrap:25:1)
at Module../src/components/inputs/types/SeatSelectInput.vue (/Users/benja/dev/ventanilla-front/dist/webpack:/src/components/inputs/types/SeatSelectInput.vue?c837:1:1)
at __webpack_require__ (/Users/benja/dev/ventanilla-front/dist/webpack:/webpack/bootstrap:25:1)
at Module../node_modules/cache-loader/dist/cjs.js?!./node_modules/@vue/cli-plugin-babel/node_modules/babel-loader/lib/index.js!./node_modules/ts-loader/index.js?!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/inputs/types/SeatMapBuilder.vue?vue&type=script&lang=ts& (/Users/benja/dev/ventanilla-front/dist/main.js:38302:102)
at __webpack_require__ (/Users/benja/dev/ventanilla-front/dist/webpack:/webpack/bootstrap:25:1)
at Module../src/components/inputs/types/SeatMapBuilder.vue?vue&type=script&lang=ts& (/Users/benja/dev/ventanilla-front/dist/webpack:/src/components/inputs/types/SeatMapBuilder.vue?905a:1:1)
at __webpack_require__ (/Users/benja/dev/ventanilla-front/dist/webpack:/webpack/bootstrap:25:1)
at Module../src/components/inputs/types/SeatMapBuilder.vue (/Users/benja/dev/ventanilla-front/dist/webpack:/src/components/inputs/types/SeatMapBuilder.vue?56f0:1:1)
at __webpack_require__ (/Users/benja/dev/ventanilla-front/dist/webpack:/webpack/bootstrap:25:1)
at Module../tests/unit/components/inputs/types/SeatMapBuilder.spec.ts (/Users/benja/dev/ventanilla-front/dist/main.js:403757:101)
at __webpack_require__ (/Users/benja/dev/ventanilla-front/dist/webpack:/webpack/bootstrap:25:1)
at run (/Users/benja/dev/ventanilla-front/dist/webpack:/node_modules/mocha-webpack/lib/entry.js:3:1)
at Array.forEach (<anonymous>)
at Object../node_modules/mocha-webpack/lib/entry.js (/Users/benja/dev/ventanilla-front/dist/webpack:/node_modules/mocha-webpack/lib/entry.js:10:1)
at __webpack_require__ (/Users/benja/dev/ventanilla-front/dist/webpack:/webpack/bootstrap:25:1)
at /Users/benja/dev/ventanilla-front/dist/webpack:/webpack/bootstrap:116:1
at Object.<anonymous> (/Users/benja/dev/ventanilla-front/dist/main.js:120:10)
at Module._compile (internal/modules/cjs/loader.js:723:30)
at Module.replacementCompile (/Users/benja/dev/ventanilla-front/node_modules/append-transform/index.js:58:13)
at _module2.default._extensions.(anonymous function) (/Users/benja/dev/ventanilla-front/node_modules/mocha-webpack/lib/util/registerRequireHook.js:148:12)
at Object.<anonymous> (/Users/benja/dev/ventanilla-front/node_modules/append-transform/index.js:62:4)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Module.require (internal/modules/cjs/loader.js:659:17)
at require (internal/modules/cjs/helpers.js:22:18)
at /Users/benja/dev/ventanilla-front/node_modules/mocha/lib/mocha.js:250:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/Users/benja/dev/ventanilla-front/node_modules/mocha/lib/mocha.js:247:14)
at Mocha.run (/Users/benja/dev/ventanilla-front/node_modules/mocha/lib/mocha.js:576:10)
at /Users/benja/dev/ventanilla-front/node_modules/mocha-webpack/lib/runner/TestRunner.js:191:27
at /Users/benja/dev/ventanilla-front/node_modules/mocha-webpack/lib/webpack/compiler/registerReadyCallback.js:26:7
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/benja/dev/ventanilla-front/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:63:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (/Users/benja/dev/ventanilla-front/node_modules/tapable/lib/Hook.js:35:21)
at emitRecords.err (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/Compiler.js:257:22)
at Compiler.emitRecords (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/Compiler.js:372:39)
at emitAssets.err (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/Compiler.js:251:10)
at hooks.afterEmit.callAsync.err (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/Compiler.js:358:14)
at _err0 (eval at create (/Users/benja/dev/ventanilla-front/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:16:1)
at callback (/Users/benja/dev/ventanilla-front/node_modules/copy-webpack-plugin/dist/index.js:126:17)
at afterEmit (/Users/benja/dev/ventanilla-front/node_modules/copy-webpack-plugin/dist/index.js:220:13)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/benja/dev/ventanilla-front/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:12:1)
at AsyncSeriesHook.lazyCompileHook [as _callAsync] (/Users/benja/dev/ventanilla-front/node_modules/tapable/lib/Hook.js:35:21)
at asyncLib.forEach.err (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/Compiler.js:355:27)
at done (/Users/benja/dev/ventanilla-front/node_modules/neo-async/async.js:2854:11)
at /Users/benja/dev/ventanilla-front/node_modules/neo-async/async.js:2805:7
at MemoryFileSystem.writeFile (/Users/benja/dev/ventanilla-front/node_modules/memory-fs/lib/MemoryFileSystem.js:328:9)
at writeOut (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/Compiler.js:339:29)
at asyncLib.forEach (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/Compiler.js:349:7)
at baseEach (/Users/benja/dev/ventanilla-front/node_modules/neo-async/async.js:2416:9)
at Object.each (/Users/benja/dev/ventanilla-front/node_modules/neo-async/async.js:2843:9)
at emitFiles (/Users/benja/dev/ventanilla-front/node_modules/webpack/lib/Compiler.js:312:13)
at Immediate._onImmediate (/Users/benja/dev/ventanilla-front/node_modules/memory-fs/lib/MemoryFileSystem.js:288:4)
at processImmediate (timers.js:632:19)
ERROR mocha-webpack exited with code 1.
=============================== Coverage summary ===============================
Statements : Unknown% ( 0/0 )
Branches : Unknown% ( 0/0 )
Functions : Unknown% ( 0/0 )
Lines : Unknown% ( 0/0 )
================================================================================
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ventas-frontend@0.1.0 test:unit: `nyc vue-cli-service test:unit --require ./tests/unit/setup.js --timeout 10000`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ventas-frontend@0.1.0 test:unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/benja/.npm/_logs/2019-06-24T16_19_47_171Z-debug.log
@silva96 Oops, my apologizes.
Can you do a vue-cli-service inspect
and show its output? I don't know about how vue's complex webpack machinaries or its implicit rules go, and it also had tripped me a few times.
After upgrading to babel 7 I started receiving the error, and none of the related issues I have found helped to solve it. Removing the istambul-instrumenter-loader rule from the webpack configuration the error disappears, bot the coverage does not work.
babel-plugin-istanbul: 5.1.0 node: 9.11.2 npm: 5.6.0
package.json
webpack.base.conf.js
webpack.test.conf.js
karma.conf.js
.babelrc