Vue.js Jest:找不到模块
我使用vue cli生成了一个应用程序,并选择Jest作为测试运行程序。 HelloWorld默认vue一切正常。 我在“.vue”中添加了以下语句:Vue.js Jest:找不到模块,vue.js,jestjs,Vue.js,Jestjs,我使用vue cli生成了一个应用程序,并选择Jest作为测试运行程序。 HelloWorld默认vue一切正常。 我在“.vue”中添加了以下语句: import aService from 'my-lib'; 当我使用以下工具运行项目时,它工作正常:npm-run-dev 但是,当我使用npm run test:unit运行测试时,我得到无法从“HelloWorld.vue”中找到模块“my lib”错误: > vue-cli-service test:unit FAIL te
import aService from 'my-lib';
当我使用以下工具运行项目时,它工作正常:npm-run-dev
但是,当我使用npm run test:unit
运行测试时,我得到无法从“HelloWorld.vue”中找到模块“my lib”
错误:
> vue-cli-service test:unit
FAIL tests/unit/example.spec.js
● Test suite failed to run
Cannot find module 'my-lib' from 'HelloWorld.vue'
93 |
94 | <script>
> 95 | import aService from 'my-lib';
| ^
96 |
97 | export default {
98 | name: 'HelloWorld',
module.exports = {
preset: '@vue/cli-plugin-unit-jest',
transformIgnorePatterns: [
"node_modules/(?!(my-lib)/)"
],
moduleDirectories: [
"node_modules"
],
};