[英]TypeError: Super expression must either be null or a function
I'm very new to unit Testing in vue js. 我对vue js中的单元测试非常陌生。 I just went through this website to learn unit testing " https://vue-test-utils.vuejs.org/guides/#testing-single-file-components-with-mocha-webpack ".
我刚刚通过这个网站学习了单元测试“ https://vue-test-utils.vuejs.org/guides/#testing-single-file-components-with-mocha-webpack ”。 while I'm practicing the examples in "mocha-webpack" I got this Error
当我在“ mocha-webpack”中练习示例时,出现此错误
WEBPACK Failed to compile with 1 error(s)
Error in ./src/Counter.vue
TypeError: Super expression must either be null or a function
at /opt/htdocs/guru/unitTest_prct/node_modules/prettier/index.js:32893:5
at /opt/htdocs/guru/unitTest_prct/node_modules/prettier/index.js:32913:4
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mdbvue@4.2.0 test: `mocha-webpack --webpack-config webpack.config.js --require test/setup.js test/**/*.spec.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mdbvue@4.2.0 test 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! /root/.npm/_logs/2018-09-06T10_28_47_073Z-debug.log
Can anyone tell me how to solve this error. 谁能告诉我如何解决此错误。 This is my Counter.vue file
这是我的Counter.vue文件
<template>
<div>
<div>
{{ count }}
<button @click="increment">Increment</button>
</div>
</div>
</template>
<script>
export default {
data () {
return {
count: 0
}
},
methods: {
increment () {
this.count++;
}
}
};
</script>
Here is my Counter.spec.js File 这是我的Counter.spec.js文件
import { shallowMount } from '@vue/test-utils'
import Counter from '../src/docs/Counter.vue'
describe('Counter.vue', () => {
it('increments count when button is clicked', () => {
const wrapper = shallowMount(Counter)
wrapper.find('button').trigger('click')
expect(wrapper.find('div').text()).toMatch('1')
})
})
It is a problem related with version 1.14.1 of prettier
, that is a NPM package used in your scenario. 这是与1.14.1版本相关的问题
prettier
,那就是在您的方案中使用的NPM包。
Indeed, looking at their GitHub repo the issue is reported. 确实,查看他们的GitHub存储库已报告了该问题。 At the moment there is a possible workaround: basically, it is to comment out line 32893 of
prettier/index.js
. 目前,有一个可能的解决方法:基本上是注释掉prettier
prettier/index.js
第32893行。
In your environment you can find the file here: /opt/htdocs/guru/unitTest_prct/node_modules/
. 在您的环境中,您可以在以下位置找到文件:
/opt/htdocs/guru/unitTest_prct/node_modules/
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.