vue-jest: TypeError: Cannot read property 'lang' of null
I am trying out your webpack template to use jest for unit testing in a new little app and am getting this error when running npm run unit:
FAIL test/unit/specs/App.spec.js
● Test suite failed to run
TypeError: Cannot read property 'lang' of null
at processScript (node_modules/jest-vue/lib/process.js:13:17)
at Object.module.exports [as process] (node_modules/jest-vue/lib/process.js:27:18)
at Object.<anonymous> (test/unit/specs/App.spec.js:1:114)
I reduced the file to an absolute minimum and I’m still getting the error.
App.spec.js
import App from '@/App'
App.vue
<template>
<div id="app">
</div>
</template>
package.json
...
"jest": "^21.2.0",
"jest-vue": "^0.7.0",
...
This is the offending line in jest-vue/lib/process.js:
function processScript (scriptPart) {
if (scriptPart.lang === 'typescript' || scriptPart.lang === 'ts') {
Which seems to make sense since I do not define a lang attribute on my script tags.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 23 (12 by maintainers)
It worked 😄
@icaioincau Try again changing your template to
<template functional>...</template>@mikemenaker @chlab I confirm that SFC with no script section do work with version 1.0.0 vue-jest
But you need to define the template as
<template functional>Thanks for posting the component @Ca4tkin 😀
I’ve pushed a fix in 1.0.3
Hi! I’ve still got error with ‘lang’ in 1.0.2 version. Any way to fix it without adding functional to template?