-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test optimization] Add Dynamic Instrumentation to jest retries (#4876)
- Loading branch information
1 parent
d19f3b0
commit 5c6d126
Showing
17 changed files
with
444 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
integration-tests/ci-visibility/dynamic-instrumentation/dependency.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = function (a, b) { | ||
const localVariable = 2 | ||
if (a > 10) { | ||
throw new Error('a is too big') | ||
} | ||
return a + b + localVariable - localVariable | ||
} |
15 changes: 15 additions & 0 deletions
15
integration-tests/ci-visibility/dynamic-instrumentation/test-hit-breakpoint.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-disable */ | ||
const sum = require('./dependency') | ||
|
||
// TODO: instead of retrying through jest, this should be retried with auto test retries | ||
jest.retryTimes(1) | ||
|
||
describe('dynamic-instrumentation', () => { | ||
it('retries with DI', () => { | ||
expect(sum(11, 3)).toEqual(14) | ||
}) | ||
|
||
it('is not retried', () => { | ||
expect(sum(1, 2)).toEqual(3) | ||
}) | ||
}) |
17 changes: 17 additions & 0 deletions
17
integration-tests/ci-visibility/dynamic-instrumentation/test-not-hit-breakpoint.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* eslint-disable */ | ||
const sum = require('./dependency') | ||
|
||
// TODO: instead of retrying through jest, this should be retried with auto test retries | ||
jest.retryTimes(1) | ||
|
||
let count = 0 | ||
describe('dynamic-instrumentation', () => { | ||
it('retries with DI', () => { | ||
const willFail = count++ === 0 | ||
if (willFail) { | ||
expect(sum(11, 3)).toEqual(14) // only throws the first time | ||
} else { | ||
expect(sum(1, 2)).toEqual(3) | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.