Skip to content

Commit 545939d

Browse files
[test optimization] Fix cypress attempt to fix (#7767)
1 parent 6c8e945 commit 545939d

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

integration-tests/cypress/cypress.spec.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ moduleTypes.forEach(({
540540
assert.ok(jsInvocationDetailsEvent, 'plain-js invocationDetails test event should exist')
541541
assert.strictEqual(
542542
jsInvocationDetailsEvent.content.metrics[TEST_SOURCE_START],
543-
246,
543+
244,
544544
'should keep invocationDetails line directly for plain JS specs without source maps'
545545
)
546546
assert.ok(
@@ -2975,11 +2975,9 @@ moduleTypes.forEach(({
29752975
testAssertionsPromise,
29762976
])
29772977

2978-
if (shouldAlwaysPass) {
2978+
if (shouldAlwaysPass || isQuarantined || isDisabled) {
29792979
assert.strictEqual(exitCode, 0)
29802980
} else {
2981-
// TODO: we need to figure out how to trick cypress into returning exit code 0
2982-
// even if there are failed tests
29832981
assert.strictEqual(exitCode, 1)
29842982
}
29852983
}
@@ -3018,9 +3016,6 @@ moduleTypes.forEach(({
30183016
* TODO:
30193017
* The spec says that quarantined tests that are not attempted to fix should be run and their result ignored.
30203018
* Cypress will skip the test instead.
3021-
*
3022-
* When a test is quarantined and attempted to fix, the spec is to run the test and ignore its result.
3023-
* Cypress will run the test, but it won't ignore its result.
30243019
*/
30253020
it('can mark tests as quarantined and tests are not skipped', async () => {
30263021
receiver.setSettings({ test_management: { enabled: true, attempt_to_fix_retries: 3 } })

packages/datadog-plugin-cypress/src/support.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,16 @@ Cypress.on('fail', (err, runnable) => {
6161
}
6262

6363
const testName = runnable.fullTitle()
64-
const { isQuarantined, isAttemptToFix } = getTestProperties(testName)
64+
const { isQuarantined, isDisabled } = getTestProperties(testName)
6565

66-
// For pure quarantined tests (not attemptToFix), suppress the failure
67-
// This makes the test "pass" from Cypress's perspective while we still track the error
68-
if (isQuarantined && !isAttemptToFix) {
69-
// Store the error so we can report it to Datadog in afterEach
66+
// Suppress failures for quarantined or disabled tests so they don't affect the exit code.
67+
// This applies regardless of attempt-to-fix status: per spec, quarantined/disabled test
68+
// results are always ignored.
69+
if (isQuarantined || isDisabled) {
7070
quarantinedTestErrors.set(testName, err)
71-
// Don't re-throw - this prevents Cypress from marking the test as failed
7271
return
7372
}
7473

75-
// For all other tests (including attemptToFix), let the error propagate normally
7674
throw err
7775
})
7876

0 commit comments

Comments
 (0)