Skip to content

Commit c8ff80a

Browse files
[test optimization] Fix vitest quarantined test fail status (#7769)
Add quarantined tests to `switchedStatuses` when their state is flipped from fail to pass. This causes the reporter to publish the error channel instead of the pass channel, so the plugin reports TEST_STATUS='fail' to Datadog while vitest still sees the test as passing (exit code 0, session passes). Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 53a032e commit c8ff80a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

integration-tests/vitest/vitest.spec.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,8 +1991,7 @@ versions.forEach((version) => {
19911991
)
19921992

19931993
if (isQuarantining) {
1994-
// TODO: do not flip the status of the test but still ignore failures
1995-
assert.strictEqual(quarantinedTest.meta[TEST_STATUS], 'pass')
1994+
assert.strictEqual(quarantinedTest.meta[TEST_STATUS], 'fail')
19961995
assert.strictEqual(quarantinedTest.meta[TEST_MANAGEMENT_IS_QUARANTINED], 'true')
19971996
} else {
19981997
assert.strictEqual(quarantinedTest.meta[TEST_STATUS], 'fail')

packages/datadog-instrumentations/src/vitest.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,9 @@ function wrapVitestTestRunner (VitestTestRunner) {
661661
}
662662
task.result.state = 'pass'
663663
} else if (isQuarantined) {
664+
if (task.result.state === 'fail') {
665+
switchedStatuses.add(task)
666+
}
664667
task.result.state = 'pass'
665668
}
666669
}

0 commit comments

Comments
 (0)