WHI*_*LOR 10 javascript testing unit-testing node.js
我有两个关于JS单元测试的问题:
1)是否有一些工具允许在更改某些文件时自动运行javascript单元测试(例如,nodemon在js更改时重新启动node.js).
2)这种策略是否适合(有效)运行单元测试?
谢谢,亚历克斯
Pap*_*les 13
对于那些致力于使用nodemon的人,nodemon -x "npm test"已经为我工作过.
nodemon --help 说:
-x, --exec app ........... execute script with "app", ie. -x "python -v".
在我们的例子npm test中,设置为通过配置我们的package.json来运行测试
例如:
"scripts": {
"test": "mocha"
},
Run Code Online (Sandbox Code Playgroud)
小智 6
使用 jest 时,nodemon 不是必需的。只需在 package.json 中设置test脚本命令即可jest --watchAll,如下所示:
"scripts": {
"test": "jest --watchAll"
}
Run Code Online (Sandbox Code Playgroud)
小智 2
查看 grunt 构建系统和监视任务。您可以设置 grunt 来监视文件更改,然后运行您想要的任何任务(测试、lint、编译等)。
https://github.com/cowboy/grunt
本教程涵盖了一些想法。http://javascriptplayground.com/blog/2012/04/grunt-js-command-line-tutorial
| 归档时间: |
|
| 查看次数: |
2370 次 |
| 最近记录: |