I have setup Idea Web Storm and can run Karma Tests successfully if the test specs are defined in the karam.conf.js.
However, if I right click on the JS file and choose 'Run MySpec.js', I get this error:
/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
Maybe it's not possible to run JS tests in this way.
Here is the config in WebStorm:

The KT config linked to the karma.conf.js file works OK as I mentioned.
Any help appreciated.
You can use fit() or fdescribe() instead of it() and describe() to achieve what is known as focussed test cases. describe("test spec", function() { it("test case 1", function() { }); fit("test case 2", function() { }); }); In the above example, only test case 2 would get executed.
I don't have a WebStorm-specifc solution for you - However, if you want to simply be able to only run certain jasmine tests instead of all of them, this is possible through use of "focused specs"
Essentially, If you change describe to fdescribe or it to fit, jasmine will only run the specs with the f prefix and ignore all others.
Here's an example:
fdescribe('Spec1', function () {
it('should do something', function () {
...
});
});
describe('Spec2', function () {
it('should do something', function () {
...
});
});
If you run jasmine tests on this file, all its in the Spec1 fdescribe block will be run.
So if you can get WebStorm to run all your specs, you can use fdescribe and fit to focus the run on only specific ones.
Just be careful not to commit your code with fit and fdescribe still in it, or you might inadvertently cause your CI server to skip running most of your specs :)
You can't run karma tests this way - the required modules are not loaded. What are you trying to do - running individual test file? There is no way to pass a spec file to karma directly - see https://github.com/karma-runner/karma/issues/553
If you like to use Node.js run configuration to run karma tests, the correct parameters would be the following:
Javascript file: /usr/local/bin/karma
application parameters: start karma.conf.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With