Sim*_*leJ 11 javascript testing mocha.js babeljs
我的Mocha测试工作正常,但是当我添加一个新模块(和测试)时,mocha停止运行我的所有测试文件,现在只运行单个新测试.
我的测试脚本:
env NODE_PATH=$NODE_PATH:$PWD/src mocha --recursive --compilers js:babel-core/register src/**/*.test.js --require babel-polyfill
Run Code Online (Sandbox Code Playgroud)
我的项目结构如下:
/src
/components
/component-name
index.js
component.js
component-name.test.js
style.scss
/util
/module-name
index.js
module-name.test.js
/some-other-module
index.js
some-other-module.test.js
Run Code Online (Sandbox Code Playgroud)
我有几个测试,/components并且/util一切正常,但是当我将一个模块放入/src(像/some-other-module)中的.test.js文件时,Mocha只运行该测试文件,而不运行其他任何一个.
Lou*_*uis 17
在传递给Mocha的模式周围加上单引号,以防止它被shell解释: 'src/**/*.test.js'
如果没有引号,您的shell会尝试扩展该模式并且成功.扩展的结果是src/some-other-module/some-other-module.test.js,这是传递给摩卡的.
在创建该文件之前,shell仍尝试扩展模式但未成功并将模式保持原样.所以摩卡得到了src/**/*.test.js,摩卡本身将其解释为全局.
如果你想知道,在Bash中,除非打开globstar选项,否则**相当于*.
| 归档时间: |
|
| 查看次数: |
7676 次 |
| 最近记录: |