Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a "run cycle overview" to documentation #3455

Merged
merged 12 commits into from
Sep 22, 2018
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overview -> 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 invoked.
Worth noting that all hooks, 'describe' and 'it' callbacks are run in the order they are defined (i.e. found in the file).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about wrap 'describe' and 'it' by ` not ' ?


``` java
Copy link
Contributor

@plroebuck plroebuck Aug 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the codefence language set to 'java'? Maybe use 'text' instead?

Copy link
Contributor

@plroebuck plroebuck Aug 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. You were highlighting the Mocha functions in red.
How about a comment to that effect?

[//]: # (Used 'java' language so Mocha globals are highlighted)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, done.

Copy link
Contributor

@plroebuck plroebuck Sep 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Markdown comment must be on its own line. Think it also requires surrounding blank lines (both before and after it).

Copy link
Contributor

@plroebuck plroebuck Sep 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also note now that the highlighting you had from before no longer occurs. Only dashed lines are shown in red (as though you had used 'text' for codefence language).

Did quick test and defining the codefence language as js seems to come closest to your original, highlighting almost all Mocha globals (after doesn't for some odd reason). Grrrr. Markdown highlighting hacks - gotta luv 'em, eh?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You didn't make any changes here. Surprised markdownlint isn't b*tching about the comment.

But does the lack of highlighting eliminate the need for the comment?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codefence highlighting/markdown comment is what has been blocking it for 3 weeks...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had missed this comment, will address it.

Copy link
Contributor Author

@craigtaub craigtaub Sep 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plroebuck tried myself agree js seemed fine and as its more preferable used js and removed the comment. If this is not right please instruct. Think this was the last remaining change.

run 'mocha spec.js'
|
spawn child process
|
|--------------> inside child process
process and apply options
|
run spec file/s
|
|--------------> per spec file
'describe' callbacks
plroebuck marked this conversation as resolved.
Show resolved Hide resolved
|
'before' root-level pre-hook
|
'before' pre-hook
|
|--------------> per test
'beforeEach' root-level pre-hook
|
'beforeEach' pre-hook
|
'it' callbacks
plroebuck marked this conversation as resolved.
Show resolved Hide resolved
|
'afterEach' post-hook
|
'afterEach' root-level post-hook
|--------------> per test end
plroebuck marked this conversation as resolved.
Show resolved Hide resolved
|
'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