From b5ce7af074d8056ffee9b944ae5a3dfd6e373df9 Mon Sep 17 00:00:00 2001 From: Jonas Amundsen Date: Sun, 19 Mar 2023 16:20:16 +0100 Subject: [PATCH] Correctly set `willBeRetried` in messages This fixes #849 [1]. [1] https://github.com/badeball/cypress-cucumber-preprocessor/issues/849 --- CHANGELOG.md | 4 ++++ features/fixtures/retried.ndjson | 2 +- lib/create-tests.ts | 12 +++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5f1af56..4b4600e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## Unreleased + +- Correctly set `willBeRetried` in messages reports, fixes [#849](https://github.com/badeball/cypress-cucumber-preprocessor/issues/849). + ## v15.1.5 - Correctly escape injected values to glob patterns, fixes [#946](https://github.com/badeball/cypress-cucumber-preprocessor/issues/946). diff --git a/features/fixtures/retried.ndjson b/features/fixtures/retried.ndjson index 3bb5f87a..967f89f2 100644 --- a/features/fixtures/retried.ndjson +++ b/features/fixtures/retried.ndjson @@ -7,7 +7,7 @@ {"testCaseStarted":{"id":"id","testCaseId":"id","attempt":0,"timestamp":{"seconds":0,"nanos":0}}} {"testStepStarted":{"testStepId":"id","testCaseStartedId":"id","timestamp":{"seconds":0,"nanos":0}}} {"testStepFinished":{"testStepId":"id","testCaseStartedId":"id","testStepResult":{"status":"FAILED","message":"some error","duration":0},"timestamp":{"seconds":0,"nanos":0}}} -{"testCaseFinished":{"testCaseStartedId":"id","timestamp":{"seconds":0,"nanos":0},"willBeRetried":false}} +{"testCaseFinished":{"testCaseStartedId":"id","timestamp":{"seconds":0,"nanos":0},"willBeRetried":true}} {"testCaseStarted":{"id":"id","testCaseId":"id","attempt":1,"timestamp":{"seconds":0,"nanos":0}}} {"testStepStarted":{"testStepId":"id","testCaseStartedId":"id","timestamp":{"seconds":0,"nanos":0}}} {"testStepFinished":{"testStepId":"id","testCaseStartedId":"id","testStepResult":{"status":"PASSED","duration":0},"timestamp":{"seconds":0,"nanos":0}}} diff --git a/lib/create-tests.ts b/lib/create-tests.ts index 122554a5..518ccd9b 100644 --- a/lib/create-tests.ts +++ b/lib/create-tests.ts @@ -808,11 +808,21 @@ export default function createTests( } } + const currentRetry = assertAndReturn( + (this.currentTest as any)?._currentRetry, + "Expected to find an attribute _currentRetry" + ); + + const retries = assertAndReturn( + (this.currentTest as any)?._retries, + "Expected to find an attribute _retries" + ); + messages.push({ testCaseFinished: { testCaseStartedId, timestamp: endTimestamp, - willBeRetried: false, + willBeRetried: currentRetry < retries, }, });