- 下载依赖
$ npm run installKarma
- 配置文件package.json
{
...
"scripts": {
"deploy": "npm run clean && npm run test && npm run dll && npm run build",
}
...
}
这样打包文件的时候就会自动进行测试。
编写测试文件之后,通过以下命令最终打包到发布环境时。
$ npm run deploy
代码测试阶段,如果代码无法通过测试用例,说明代码存在问题,请寻找相关源码进行调试,否则无法正常打包。
通过以下命令会测试所有相关的测试文件
$ npm run test
测试完成后将会生成测试的相关文件
文件地址: /build/coverage
可通过 /build/coverage/lcov-report/index.html
查看具体数据
通过以下命令可持续监听测试文件
$ npm run test:dev
引入自己喜欢的断言库
- 文件地址:
/tests/bundler.js