mochajs/mocha — pull request #1445 by rprieto (2014-11-24 06:10:42+00:00)
Title: Support for --tags to include/exclude tests based on some optional tagging

As discussed in #928, this is a tentative PR for tagging support in the `bdd` interface. I hope this is not against the guidelines (PR for a new feature), but it will be easier to discuss what's feasible with some visibility on the code changes.

- you can optionally pass an array of tags as the first argument to `describe` and `it`
- by default, all tests always run
- you can specify `--tags` to run a subset of the tests
- tests that don't match the filter are marked as pending

```js
describe('my service', function() {
it('test 1', function() {});
describe(['integration'], 'backend connectivity', function() {
describe(['fast'], 'quick tests', function() {
it('test 2', function() {});
});
it(['slow'], 'test 3', function() {});
});
});
```

- `mocha` runs everything
- `mocha --tags "not:integration"` runs test `1`
- `mocha --tags "is:integration"` runs tests `2` and `3`
- `mocha --tags "is:integration not:slow"` runs test `2`

If this looks good, happy to look into how to unit test & document it.
Cheers