jasminejasmine-node

how do I run a single test from the command line using jasmine 2.0


As the title says, I would like to run a single test, not the whole spec. The naive way I tried was using a case like this:

describe("MyCase",function() {
    it("has a test",function() {
        expect(something).toBe(something);
    }

    it("has another test",function() {
        expect(something_else).toBe(something_else);
    }
}

This is saved in a file called MyCase.spec.js (if this matters). I would have thought that it would be possible to run just the first case using the following from the command line:

jasmine-node --match="MyCase has a test"

But this is apperantly not the way to do it. So how is it done?

Thanks!


Solution

  • Current documentation (Jasmine v9) for filtering tests is here.

    To run single test case from a single *.spec.js file, you can use syntax like this:

    npx jasmine spec\lib\build\bundled-source.spec.mjs --filter="transform saves cache"
    

    You can use both forward / and backward \ slashes in the file name on Windows.

    Wild cards are also possible, both in the file name and in the test case name. For example:

    npx jasmine spec/**/*.spec.js --filter="transform*"