Skip to content

Commit

Permalink
Added a "run cycle overview" to documentation (#3455)
Browse files Browse the repository at this point in the history
* run cycle overview
* adjust flow format
* add to table of contents
* code highlighting points of interest
* remove highlighting
* java code highlighting
* fix lint error
* language change. swap parse+exec for run
* use back-ticks for it + describe. uppercase title.
* invoked to executed
* add comment, make ui-generic, swap arrows
* Swap java back to js as highlighting the same
  • Loading branch information
craigtaub authored and outsideris committed Sep 22, 2018
1 parent d401ee1 commit 69bc0c7
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Mocha is a feature-rich JavaScript test framework running on [Node.js](https://n

- [Installation](#installation)
- [Getting Started](#getting-started)
- [Run Cycle Overview](#run-cycle-overview)
- [Detects Multiple Calls to `done()`](#detects-multiple-calls-to-done)
- [Assertions](#assertions)
- [Asynchronous Code](#asynchronous-code)
Expand Down Expand Up @@ -142,6 +143,47 @@ Then run tests with:
$ npm test
```

## Run Cycle Overview

A brief outline on the order Mocha's components are executed.
Worth noting that all hooks, `describe` and `it` callbacks are run in the order they are defined (i.e. found in the file).

``` js
run 'mocha spec.js'
|
spawn child process
|
|--------------> inside child process
process and apply options
|
run spec file/s
|
|--------------> per spec file
suite callbacks (e.g., 'describe')
|
'before' root-level pre-hook
|
'before' pre-hook
|
|--------------> per test
'beforeEach' root-level pre-hook
|
'beforeEach' pre-hook
|
test callbacks (e.g., 'it')
|
'afterEach' post-hook
|
'afterEach' root-level post-hook
|<-------------- per test end
|
'after' post-hook
|
'after' root-level post-hooks
|<-------------- per spec file end
|<-------------- inside child process end
```

## Detects Multiple Calls to `done()`

If you use callback-based async tests, Mocha will throw an error if `done()` is called multiple times. This is handy for catching accidental double callbacks.
Expand Down

0 comments on commit 69bc0c7

Please sign in to comment.