-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[docs] Add synchronous test.each setup #7150
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,6 +192,23 @@ Jest takes advantage of new features added to Node 6. We recommend that you upgr | |
|
||
Make sure you are not using the `babel-plugin-istanbul` plugin. Jest wraps Istanbul, and therefore also tells Istanbul what files to instrument with coverage collection. When using `babel-plugin-istanbul`, every file that is processed by Babel will have coverage collection code, hence it is not being ignored by `coveragePathIgnorePatterns`. | ||
|
||
## Defining Tests | ||
|
||
Tests much be defined synchronously for Jest to be able to collect your tests. | ||
|
||
This means when you are using `test.each` you cannot set the table asynchronously within a `beforeEach` / `beforeAll`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO we should have the example above the mention of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in 716bc5f :) |
||
|
||
As an example to show why this is the case, imagine we wrote a test like so: | ||
|
||
```js | ||
// Don't do this it will not work | ||
setTimeout(() => { | ||
it('passes', () => expect(1).toBe(1)); | ||
}, 0); | ||
``` | ||
|
||
When Jest runs your test to collect the `test`s it will not find any because we have set the definition to happen asynchronously on the next tick of the event loop. | ||
|
||
## Still unresolved? | ||
|
||
See [Help](/help.html). |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,6 +193,23 @@ Jest takes advantage of new features added to Node 6. We recommend that you upgr | |
|
||
Make sure you are not using the `babel-plugin-istanbul` plugin. Jest wraps Istanbul, and therefore also tells Istanbul what files to instrument with coverage collection. When using `babel-plugin-istanbul`, every file that is processed by Babel will have coverage collection code, hence it is not being ignored by `coveragePathIgnorePatterns`. | ||
|
||
## Defining Tests | ||
|
||
Tests much be defined synchronously for Jest to be able to collect your tests. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
|
||
This means when you are using `test.each` you cannot set the table asynchronously within a `beforeEach` / `beforeAll`. | ||
|
||
As an example to show why this is the case, imagine we wrote a test like so: | ||
|
||
```js | ||
// Don't do this it will not work | ||
setTimeout(() => { | ||
it('passes', () => expect(1).toBe(1)); | ||
}, 0); | ||
``` | ||
|
||
When Jest runs your test to collect the `test`s it will not find any because we have set the definition to happen asynchronously on the next tick of the event loop. | ||
|
||
## Still unresolved? | ||
|
||
See [Help](/help.html). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/much/must