【发布时间】:2019-07-01 13:18:25
【问题描述】:
在 Windows 7 上。使用 VueJS UI 实用程序安装了一个新的 vue 项目。设置单元测试/启用开玩笑。添加了通天塔。
在命令行运行“npm test”会返回'Error: no test specified'。
我在 package.json 文件中设置了典型的 "scripts": { "vue-cli-service test:unit" }。
jest.config.js 具有预期的匹配模式:
{ testMatch: [
'**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
] }
因此,它甚至找不到位于 tests/unit/example.spec.js 中的示例文件。
奇怪的是,我可以让它找到我直接从 node_modules 目录运行的测试,使用vue-cli-service:
node_modules\.bin\vue-cli-service test:unit
从那里我得到了一个 babel transpile 问题(它无法识别 example.spec.js 文件中的 ES6 import 命令).. 这是另一个噩梦,也许不适合这篇文章。
尝试更新 npm(使用 6.9.2)。 Vue cli 版本是3.8.2。尝试删除 node_modules 目录。
非常感谢任何帮助。
运行npm test后,错误如下:
> testing_research@0.1.0 test C:\Users\allan.luchenitser\sandbox\testing_research
> echo 'Error: no test specified'
'Error: no test specified'
再次感谢,
【问题讨论】:
标签: javascript node.js unit-testing vue.js babeljs