-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Fix retryTimes and add e2e regression test #6762
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
Changes from 2 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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /** | ||
| * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
| 'use strict'; | ||
|
|
||
| const path = require('path'); | ||
| const fs = require('fs'); | ||
|
|
||
| const countPath = path.join(__dirname, '.tries'); | ||
|
|
||
| beforeAll(() => { | ||
| fs.writeFileSync(countPath, '0', 'utf8'); | ||
| }); | ||
|
|
||
| jest.retryTimes(3); | ||
|
|
||
| it('retries', () => { | ||
| const tries = parseInt(fs.readFileSync(countPath, 'utf8'), 10); | ||
| fs.writeFileSync(countPath, `${tries + 1}`, 'utf8'); | ||
| expect(tries).toBeGreaterThanOrEqual(2); | ||
| }); | ||
|
|
||
| afterAll(() => { | ||
| // cleanup | ||
| fs.unlinkSync(countPath); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,10 @@ const _runTestsForDescribeBlock = async (describeBlock: DescribeBlock) => { | |
| let numRetriesAvailable = retryTimes; | ||
|
|
||
| while (numRetriesAvailable > 0 && test.errors.length > 0) { | ||
| // Clear errors so retries occur | ||
| // TODO: consider creating test.hookErrors and test.errors | ||
| test.errors = []; | ||
|
||
|
|
||
| await _runTest(test); | ||
| numRetriesAvailable--; | ||
| } | ||
|
|
||
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.
thinking about it, is it better to be more explicit about the number of previous tries on the final retry?
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.
Yeah good call