Skip to content

Commit 9febfaf

Browse files
committed
docs
1 parent fd572f5 commit 9febfaf

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

docs/index.md

+39-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Mocha is a feature-rich JavaScript test framework running on [Node.js][] and in
2222
- [test coverage reporting](#wallabyjs)
2323
- [string diff support](#diffs)
2424
- [javascript API for running tests](#more-information)
25-
- proper exit status for CI support etc
2625
- [auto-detects and disables coloring for non-ttys](#reporters)
2726
- [async test timeout support](#delayed-root-suite)
2827
- [test retry support](#retry-tests)
@@ -36,7 +35,6 @@ Mocha is a feature-rich JavaScript test framework running on [Node.js][] and in
3635
- [auto-exit to prevent "hanging" with an active loop](#-exit)
3736
- [easily meta-generate suites](#markdown) & [test-cases](#list)
3837
- [config file support](#-config-path)
39-
- clickable suite titles to filter test execution
4038
- [node debugger support](#-inspect-inspect-brk-inspect)
4139
- [node native ES modules support](#nodejs-native-esm-support)
4240
- [detects multiple calls to `done()`](#detects-multiple-calls-to-done)
@@ -449,9 +447,43 @@ setTimeout(function() {
449447
}, 5000);
450448
```
451449

450+
### Failing Hooks
451+
452+
Upon a failing `before` hook all tests in the current suite and also its nested suites will be skipped. Skipped tests are included in the test results and marked as **skipped**. A skipped test is not considered a failed test.
453+
454+
```js
455+
describe('outer', function() {
456+
before(function() {
457+
throw new Error('Exception in before hook');
458+
});
459+
460+
it('should skip this outer test', function() {
461+
// will be skipped and listed as 'skipped'
462+
});
463+
464+
after(function() {
465+
// will be executed
466+
});
467+
468+
describe('inner', function() {
469+
before(function() {
470+
// will be skipped
471+
});
472+
473+
it('should skip this inner test', function() {
474+
// will be skipped and listed as 'skipped'
475+
});
476+
477+
after(function() {
478+
// will be skipped
479+
});
480+
});
481+
});
482+
```
483+
452484
## Pending Tests
453485

454-
"Pending"--as in "someone should write these test cases eventually"--test-cases are simply those _without_ a callback:
486+
"Pending" - as in "someone should write these test cases eventually" - test-cases are simply those _without_ a callback:
455487

456488
```js
457489
describe('Array', function() {
@@ -462,7 +494,9 @@ describe('Array', function() {
462494
});
463495
```
464496

465-
Pending tests will be included in the test results, and marked as pending. A pending test is not considered a failed test.
497+
By appending `.skip()`, you may also tell Mocha to ignore a test: [inclusive tests](#inclusive-tests).
498+
499+
Pending tests will be included in the test results, and marked as **pending**. A pending test is not considered a failed test.
466500

467501
## Exclusive Tests
468502

@@ -1641,7 +1675,7 @@ mocha.setup({
16411675
### Browser-specific Option(s)
16421676

16431677
Browser Mocha supports many, but not all [cli options](#command-line-usage).
1644-
To use a [cli option](#command-line-usage) that contains a "-", please convert the option to camel-case, (eg. `check-leaks` to `checkLeaks`).
1678+
To use a [cli option](#command-line-usage) that contains a "-", please convert the option to camel-case, (e.g. `check-leaks` to `checkLeaks`).
16451679

16461680
#### Options that differ slightly from [cli options](#command-line-usage):
16471681

0 commit comments

Comments
 (0)