-
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 support for Vitest (#…
- Loading branch information
1 parent
3296eb8
commit b771888
Showing
7 changed files
with
288 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export function sum (a, b) { | ||
const localVar = 10 | ||
if (a > 10) { | ||
throw new Error('a is too large') | ||
} | ||
return a + b + localVar - localVar | ||
} |
18 changes: 18 additions & 0 deletions
18
integration-tests/ci-visibility/vitest-tests/breakpoint-not-hit.mjs
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,18 @@ | ||
import { describe, test, expect } from 'vitest' | ||
import { sum } from './bad-sum' | ||
|
||
let numAttempt = 0 | ||
|
||
describe('dynamic instrumentation', () => { | ||
test('can sum', () => { | ||
const shouldFail = numAttempt++ === 0 | ||
if (shouldFail) { | ||
expect(sum(11, 2)).to.equal(13) | ||
} else { | ||
expect(sum(1, 2)).to.equal(3) | ||
} | ||
}) | ||
test('is not retried', () => { | ||
expect(sum(1, 2)).to.equal(3) | ||
}) | ||
}) |
11 changes: 11 additions & 0 deletions
11
integration-tests/ci-visibility/vitest-tests/dynamic-instrumentation.mjs
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,11 @@ | ||
import { describe, test, expect } from 'vitest' | ||
import { sum } from './bad-sum' | ||
|
||
describe('dynamic instrumentation', () => { | ||
test('can sum', () => { | ||
expect(sum(11, 2)).to.equal(13) | ||
}) | ||
test('is not retried', () => { | ||
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