Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run single Jasmine test in IntelliJ IDEA

Is it possible to run single Jasmine test it or suite describe in IntelliJ from popup menu as it possible with JUnit or TestNG fremeworks?

Now I can only execute tests by running karma.conf.js that will grab all specs and run them which is not exactly what I want.

Updates

This is known issue please upvote it.

like image 744
Anton Dozortsev Avatar asked Dec 17 '16 18:12

Anton Dozortsev


People also ask

How do I run a single test case in IntelliJ?

Rerun a single testRight-click a test on the Test Runner tab of the Run tool window and select Run 'test name'.

How do I run a specific test case in Jasmine?

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.

How do I run a specific junit test in IntelliJ?

Show activity on this post. Open the class where the tests are located and check the part where inteliJ shows the the number of lines, at the beginning of each test method there is a green icon (looks like a play button) just hit that icon and the specific test method will be executed.


Video Answer


3 Answers

You don't need Intellij's help if you are trying to run a single unit test or a single test suite while using Jasmine. You can do that with their feature of fit() and fdescribe(). Here, prepending it(...) and describe(...) with f says those are focused tests/test suites.

Quoting the documentation (Jasmine 2.1 and above),

Focusing specs will make it so that they are the only specs that run.

Any spec declared with fit is focused. You can focus on a describe with fdescribe

like image 128
tanmay Avatar answered Oct 18 '22 19:10

tanmay


You could follow this issue in YouTrack - https://youtrack.jetbrains.com/issue/WEB-13173.

We have supported --grep[1] option for jasmine in karma already. But there are some open discussions about problems in large projects[2]

[1] - https://github.com/karma-runner/karma-jasmine/pull/56

[2] - https://github.com/karma-runner/karma/issues/1235

Thanks!

like image 30
maksimr Avatar answered Oct 18 '22 20:10

maksimr


With WebStorm 2017.1 it's possible to use RunConfiguration producer to run a single Karma test: https://github.com/develar/ij-rc-producer

like image 37
Ekaterina Prigara Avatar answered Oct 18 '22 20:10

Ekaterina Prigara