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

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 () {
        // ...
    });

});

In core since 2.1 with fit and fdescribe.


You can run a single spec by using the url for the spec

describe("MySpec", function() { 
  it('function 1', function() { 
    //... 
  }) 

  it('function 2', function() { 
    //... 
  } 

}) 

Now you can run just the whole spec by this url http://localhost:8888?spec=MySpec and a the first test with http://localhost:8888?spec=MySpec+function+1

Tags:

Jasmine