How do I focus on one spec in jasmine.js?

Dane O'Connor picture Dane O'Connor · Dec 15, 2011 · Viewed 90.3k times · Source

I have a bunch of failing specs from a rather large architectural change. I'd like to work on fixing them one by one by tagging each one with 'focus'.

Does jasmine.js have a feature like this? I swore I read at one point that it does but I don't see it in the docs.

Answer

Hudvoy picture Hudvoy · May 21, 2014

When using Karma, you can enable only one test with fit or fdescribe (iit and ddescribe in Jasmine before 2.1).


This only runs Spec1:

// or "ddescribe" in Jasmine prior 2.1
fdescribe('Spec1', function () {
    it('should do something', function () {
        // ...
    });
});

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

This only runs testA:

describe('Spec1', function () {

    // or "iit" in Jasmine prior 2.1
    fit('testA', function () {
        // ...
    });

    it('testB', function () {
        // ...
    });

});