javascript - JS单元测试: run tests on file changes (like nodemon)

标签 javascript unit-testing node.js testing

我有两个关于 JS 单元测试的问题:

1) 是否有一些工具允许在某些文件更改时自动运行 javascript 单元测试(例如 nodemon 在 js 更改时重新启动 node.js)。

2) 这种策略是否适合(有效)运行单元测试?

谢谢, 亚历克斯

最佳答案

对于那些致力于使用 nodemon 的人来说,nodemon -x "npm test" 对我有用。

一点解释

nodemon --help 说:

-x, --exec app ...... 用“app”执行脚本,即。 -x "python -v"。

在我们的例子中,npm test 被设置为通过配置我们的 package.json 来运行测试

例如:

"scripts": {
  "test": "mocha"
},

关于javascript - JS单元测试: run tests on file changes (like nodemon),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11377392/

相关文章:

javascript - 平面着色器 (fss.js) 大小为 100%?

java - 使用 PowerMock 模拟单例的 getInstance

node.js - 无法使用 npm 安装 *sequelize*

javascript - 在 NodeJS 中的事件回调之间共享变量

javascript - 尝试从 URL 解析 JSON 文件

javascript - Raphael.js 如何为路径设置属性?

c# - 通信协议(protocol)的单元测试

unit-testing - 是否可以在 ExUnit 测试中 stub (模拟?)Ecto.UUID.generate?

node.js - NodeJS : Hapi + Mongoose | return on a callback not working

javascript - this 在 render() 中的一个函数中