Simon Lang
Simon Lang

Reputation: 42635

Mocha list only skipped tests

I have hundreds of tests in mocha, tens of which are being skipped.

I would like to run the suite, but only listing the skipped ones, so I can address them.

Does anyone know a way to achieve this? There does not seem to be a command line flag

Upvotes: 5

Views: 1404

Answers (1)

chinoy
chinoy

Reputation: 172

Mocha comes with a built-in JSON reporter. The output JSON lists all the skipped test cases. For example

mocha -R JSON > test-report.json

Here the test-report.json file should have the following structure.

{
    stats: {...},
    tests: [...],
    pending: [...],
    failures: [...],
    passes: [...]
}

The "pending" key should have all the skipped test cases.

Upvotes: 3

Related Questions