Ole
Ole

Reputation: 47090

Running an individual mocha test from VSCode

I have created a test project that enables Mocha tests to be written in typescript and it also as Istanbul integration via nyc.

All tests can be run via the console statement npm test. I'd also like to be able to run them individually by either right clicking and selecting run test or some other means in VSCode. So for example if this test hello.spec.ts is open in the editor, run just that test. Any ideas?

Upvotes: 2

Views: 1510

Answers (2)

Mike Kenyanya
Mike Kenyanya

Reputation: 42

.only will make the test run on only the specified describe or it statement(s)

describe.only('blah blah', function(){
it.only('should...', function() {

//test here

})
})

.skip will exclude the specified describe or it statement(s)

 describe.skip('blah blah', function(){
it.skip('should...', function() {

//test here

})
})

Upvotes: 2

Mike Lischke
Mike Lischke

Reputation: 53502

Mocha allows to modify test spec calls (describe and it) to be prefixed with f or x, where f means focused and x means disabled. Hence by writing fdescribe() or fit() you focus on this test (case) and ignore (don't run) all others.

Upvotes: 1

Related Questions