gpt4 book ai didi

angularjs - 通过右键菜单在 Web Storm 中运行单个 Karma Jasmine 测试

转载 作者:行者123 更新时间:2023-12-03 06:23:57 25 4
gpt4 key购买 nike

我已经设置了 Idea Web Storm,并且如果 karam.conf.js 中定义了测试规范,则可以成功运行 Karma 测试。

但是,如果我右键单击 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

也许无法以这种方式运行 JS 测试。

这是WebStorm中的配置: enter image description here

链接到 karma.conf.js 文件的 KT 配置工作正常,正如我提到的。

任何帮助表示赞赏。

最佳答案

我没有适合您的 WebStorm 特定解决方案 - 但是,如果您只想仅运行某些 jasmine 测试而不是全部测试,可以通过使用“focused specs

本质上,如果将 describe 更改为 fdescribe 或将 it 更改为 fit,jasmine 将仅运行规范带有 f 前缀并忽略所有其他。

这是一个例子:

fdescribe('Spec1', function () {

it('should do something', function () {
...
});
});

describe('Spec2', function () {

it('should do something', function () {
...
});
});

如果您对此文件运行 jasmine 测试,则 Spec1 fdescribe block 中的所有 it 都将运行。

因此,如果您可以让 WebStorm 运行所有您的规范,您可以使用 fdescribefit 将运行集中在特定规范上.

请小心,不要在提交代码时仍然包含 fitfdescribe,否则您可能会无意中导致 CI​​ 服务器跳过运行大部分规范:)

关于angularjs - 通过右键菜单在 Web Storm 中运行单个 Karma Jasmine 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23629720/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com