-
Notifications
You must be signed in to change notification settings - Fork 312
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 mocha retries (#4944)
- Loading branch information
1 parent
b6c11a6
commit ccc13e2
Showing
10 changed files
with
330 additions
and
52 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
integration-tests/ci-visibility/dynamic-instrumentation/is-jest.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 () { | ||
try { | ||
return typeof jest !== 'undefined' | ||
} catch (e) { | ||
return false | ||
} | ||
} |
15 changes: 11 additions & 4 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 |
---|---|---|
@@ -1,15 +1,22 @@ | ||
/* eslint-disable */ | ||
const sum = require('./dependency') | ||
const isJest = require('./is-jest') | ||
const { expect } = require('chai') | ||
|
||
// TODO: instead of retrying through jest, this should be retried with auto test retries | ||
jest.retryTimes(1) | ||
if (isJest()) { | ||
jest.retryTimes(1) | ||
} | ||
|
||
describe('dynamic-instrumentation', () => { | ||
it('retries with DI', () => { | ||
expect(sum(11, 3)).toEqual(14) | ||
it('retries with DI', function () { | ||
if (this.retries) { | ||
this.retries(1) | ||
} | ||
expect(sum(11, 3)).to.equal(14) | ||
}) | ||
|
||
it('is not retried', () => { | ||
expect(sum(1, 2)).toEqual(3) | ||
expect(1 + 2).to.equal(3) | ||
}) | ||
}) |
15 changes: 11 additions & 4 deletions
15
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 |
---|---|---|
@@ -1,17 +1,24 @@ | ||
/* eslint-disable */ | ||
const sum = require('./dependency') | ||
const isJest = require('./is-jest') | ||
const { expect } = require('chai') | ||
|
||
// TODO: instead of retrying through jest, this should be retried with auto test retries | ||
jest.retryTimes(1) | ||
if (isJest()) { | ||
jest.retryTimes(1) | ||
} | ||
|
||
let count = 0 | ||
describe('dynamic-instrumentation', () => { | ||
it('retries with DI', () => { | ||
it('retries with DI', function () { | ||
if (this.retries) { | ||
this.retries(1) | ||
} | ||
const willFail = count++ === 0 | ||
if (willFail) { | ||
expect(sum(11, 3)).toEqual(14) // only throws the first time | ||
expect(sum(11, 3)).to.equal(14) // only throws the first time | ||
} else { | ||
expect(sum(1, 2)).toEqual(3) | ||
expect(sum(1, 2)).to.equal(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
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.