JAR*_*ARC 17 jasmine webstorm angularjs karma-runner karma-jasmine
如果测试规范在中定义,我已经设置Idea Web Storm
并可以Karma
成功运行测试karam.conf.js
.
但是,如果我右键单击JS文件并选择"运行MySpec.js",我会收到此错误:
/usr/bin/node MyTestSpec.js
/Users/dev/WebstormProjects/demow/test/MyTestSpec.js:4
describe('Activate wallet controller --', function () {
^
ReferenceError: describe is not defined
at Object.<anonymous> (/Users/dev/WebstormProjects/demow/test/MyTestSpec.js:4:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
Process finished with exit code 8
Run Code Online (Sandbox Code Playgroud)
也许以这种方式运行JS测试是不可能的.
这是配置WebStorm
:
如上所述,链接到karma.conf.js文件的KT配置工作正常.
任何帮助赞赏.
Jon*_*oth 12
我没有适合您的WebStorm专用解决方案 - 但是,如果您只想运行某些茉莉花测试而不是所有这些测试,可以通过使用" 聚焦规格 "来实现
从本质上讲,如果更改describe
到fdescribe
或it
到fit
,茉莉将只运行与规格f
的前缀,而忽略所有其他人.
这是一个例子:
fdescribe('Spec1', function () {
it('should do something', function () {
...
});
});
describe('Spec2', function () {
it('should do something', function () {
...
});
});
Run Code Online (Sandbox Code Playgroud)
如果对此文件运行jasmine测试,则将运行块中的所有it
s Spec1
fdescribe
.
因此,如果您可以让WebStorm运行所有规范,则可以使用fdescribe
和fit
仅将运行集中在特定的规范上.
请注意不要将代码提交fit
并fdescribe
仍然在其中,否则您可能会无意中导致CI服务器跳过运行大多数规范:)
您无法以这种方式运行业力测试 - 未加载所需的模块。您想做什么 - 运行单独的测试文件?无法直接将规范文件传递给 karma - 请参阅https://github.com/karma-runner/karma/issues/553
如果您想使用 Node.js 运行配置来运行 karma 测试,则正确的参数如下:
JavaScript 文件:/usr/local/bin/karma
应用程序参数:启动 karma.conf.js
归档时间: |
|
查看次数: |
3921 次 |
最近记录: |