Skip to content

Commit

Permalink
Update Jest Object docs for retryTimes. Use symbol for global lookup.
Browse files Browse the repository at this point in the history
  • Loading branch information
palmerj3 committed Jun 25, 2018
1 parent 3a7c127 commit 6e4c1aa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
12 changes: 11 additions & 1 deletion docs/JestObjectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,18 @@ test('will fail', () => {

To run with jest circus:

Install jest-circus

```
yarn add --dev jest-circus
```
JEST_CIRCUS=1 jest

Then set as the testRunner in your jest config:

```js
module.exports = {
testRunner: 'jest-circus/runner',
};
```

Returns the `jest` object for chaining.
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/src/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const _runTestsForDescribeBlock = async (describeBlock: DescribeBlock) => {
}

// Tests that fail and are retried we run after other tests
const retryTimes = parseInt(global.retryTimes, 10) || 0;
const retryTimes = parseInt(global[Symbol.for('RETRY_TIMES')], 10) || 0;
const deferredRetryTests = [];

for (const test of describeBlock.tests) {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-runtime/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ class Runtime {
};

const retryTimes = (numTestRetries: number) => {
this._environment.global.retryTimes = numTestRetries;
this._environment.global[Symbol.for('RETRY_TIMES')] = numTestRetries;
return jestObject;
};

Expand Down
2 changes: 1 addition & 1 deletion types/Jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type Jest = {|
resetModuleRegistry(): Jest,
resetModules(): Jest,
restoreAllMocks(): Jest,
retryTimes(numRetries: number): Jest,
runAllImmediates(): void,
runAllTicks(): void,
runAllTimers(): void,
Expand All @@ -45,7 +46,6 @@ export type Jest = {|
methodName: string,
accessType?: 'get' | 'set',
): JestMockFn,
retryTimes(numRetries: number): Jest,
unmock(moduleName: string): Jest,
useFakeTimers(): Jest,
useRealTimers(): Jest,
Expand Down

0 comments on commit 6e4c1aa

Please sign in to comment.