Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run only certain tests in karma?

I have karma config set up correctly, config file, running in the background, just great. As soon as I change and save a file, it reruns the tests.... all 750 of the unit tests. I want to be able to run just a few. Short of manually hacking the config file or commenting out hundreds of tests across many files, is there any easy way to do it?

E.g. when running command line server tests using say mocha, I just use regexp: mocha -g 'only tests that I want'. Makes it much easier to debug and quickly check.

like image 786
deitch Avatar asked Oct 28 '14 08:10

deitch


People also ask

How do I run a specific test in Jasmine?

You can use fit() or fdescribe() instead of it() and fdescribe() to achieve what is known as focussed test cases. describe("test spec", function() { it("test case 1", function() { }); fit("test case 2", function() { }); });

How does Karma test Runner work?

Karma is essentially a tool which spawns a web server that executes source code against test code for each of the browsers connected. The results of each test against each browser are examined and displayed via the command line to the developer such that they can see which browsers and tests passed or failed.


1 Answers

So now I feel foolish. mocha supports a very narrow version of regexp matching.

This runs all tests

describe('all tests',function(){
   describe('first tests',function(){
   });
   describe('second tests',function(){
   });
});

This runs just 'first tests'

describe('all tests',function(){
   describe.only('first tests',function(){
   });
   describe('second tests',function(){
   });
});

You can also do it.only()

I should have noticed that. Sigh.

like image 89
deitch Avatar answered Jan 04 '23 06:01

deitch