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

Improve documentation of describe and test ordering. #5217

Merged
merged 5 commits into from
Jan 3, 2018

Conversation

daphtdazz
Copy link
Contributor

Summary

There is no documentation of the order in which describe and test handlers are run, nor any mention of any guarantees that jest makes about their synchronicity. I believe the intention is that tests within a single file are always run one after another unless test.concurrent is used, so I wanted to formalize that in the docs.

Obviously if that's not true it would be good to see an explanation in the docs of why!

Test plan

Docs changes only and I've checked visually the markdown renders fine.

Explain that describe blocks are executed first (I've had annoying things where describes were being used to set up state instead of before* hooks), note that tests are run serially in the order they are discovered, and add a note about `test.concurrent`.
@codecov-io
Copy link

codecov-io commented Jan 3, 2018

Codecov Report

Merging #5217 into master will decrease coverage by 0.11%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #5217      +/-   ##
=========================================
- Coverage   60.91%   60.8%   -0.12%     
=========================================
  Files         202     201       -1     
  Lines        6731    6707      -24     
  Branches        3       3              
=========================================
- Hits         4100    4078      -22     
+ Misses       2630    2628       -2     
  Partials        1       1
Impacted Files Coverage Δ
packages/jest-editor-support/src/Runner.js 50.94% <0%> (-12.22%) ⬇️
packages/jest-editor-support/src/types.js

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ca5d0fc...d8a83cc. Read the comment docs.

Copy link
Member

@cpojer cpojer left a comment

Choose a reason for hiding this comment

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

Thanks for submitting a PR! Mind making the changes from the inline comments?

@@ -147,6 +147,67 @@ describe('Scoped / Nested block', () => {
// 1 - afterAll
```

### Order of execution of describe and test blocks

Jest executes all describe handlers in a test file *before* it executes any of the actual tests. This is another reason to do setup and teardown in `before*` and `after*` handlers rather in the describe blocks. Once the describe blocks are complete, by default jest runs all the tests serially in the order they were encountered in the collection phase, waiting for each to finish and be tidied up before moving on.
Copy link
Member

Choose a reason for hiding this comment

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

Can you capitalize Jest in the middle of the paragraph here? :)

// test for describe inner 2
```

### Concurrent tests
Copy link
Member

Choose a reason for hiding this comment

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

Do you mind removing this section again? test.concurrent has some shortcomings and I would prefer not to document it as we may change it in a future release to be better supported.

@daphtdazz
Copy link
Contributor Author

Thanks @cpojer , I’ve made those changes.

@cpojer cpojer merged commit 4eded0c into jestjs:master Jan 3, 2018
@cpojer
Copy link
Member

cpojer commented Jan 3, 2018

Awesome, thank you!

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants