From 8f2ff573fba98af81d5c114b681b62b8aed12b1e Mon Sep 17 00:00:00 2001 From: David Goss Date: Fri, 3 Sep 2021 12:47:27 +0100 Subject: [PATCH] chore: update @cucumber/* dependencies, fix willBeRetried usage (#1776) * latest dependencies * make it just about compile * fix test case runner * fix summary helper * fix formatters (ish) * fix last bit in formatters * update fixtures for feature tests * fix attachments cck * hook up retry cck * lint * update doc * update lockfile --- compatibility/cck_spec.ts | 14 +- .../features/attachments/attachments.ts | 21 +- compatibility/features/retry/retry.ts | 25 ++ docs/migration.md | 3 +- .../formatters/failed.message.json.ts | 2 +- .../formatters/passed-rule.message.json.ts | 2 +- .../passed-scenario.message.json.ts | 2 +- .../formatters/retried.message.json.ts | 4 +- package-lock.json | 222 ++++++++---------- package.json | 20 +- src/formatter/helpers/event_data_collector.ts | 11 +- src/formatter/helpers/issue_helpers.ts | 15 +- src/formatter/helpers/summary_helpers.ts | 30 +-- .../helpers/test_case_attempt_formatter.ts | 5 +- src/formatter/json_formatter.ts | 2 +- src/formatter/progress_bar_formatter.ts | 2 +- src/formatter/summary_formatter.ts | 14 +- src/runtime/parallel/coordinator.ts | 2 +- src/runtime/step_runner.ts | 1 - src/runtime/test_case_runner.ts | 26 +- src/runtime/test_case_runner_spec.ts | 12 +- 21 files changed, 227 insertions(+), 208 deletions(-) create mode 100644 compatibility/features/retry/retry.ts diff --git a/compatibility/cck_spec.ts b/compatibility/cck_spec.ts index 42133765d..95ad589d0 100644 --- a/compatibility/cck_spec.ts +++ b/compatibility/cck_spec.ts @@ -26,16 +26,20 @@ describe('Cucumber Compatibility Kit', () => { const suiteName = match[1] const extension = match[2] it(`passes the cck suite for '${suiteName}'`, async () => { - const args = [ - 'node', - path.join(PROJECT_PATH, 'bin', 'cucumber-js'), - ].concat([ + const cliOptions = [ `${CCK_FEATURES_PATH}/${suiteName}/${suiteName}${extension}`, '--require', `${CCK_IMPLEMENTATIONS_PATH}/${suiteName}/${suiteName}.ts`, '--profile', 'cck', - ]) + ] + if (suiteName === 'retry') { + cliOptions.push('--retry', '2') + } + const args = [ + 'node', + path.join(PROJECT_PATH, 'bin', 'cucumber-js'), + ].concat(cliOptions) const stdout = new PassThrough() try { await new Cli({ diff --git a/compatibility/features/attachments/attachments.ts b/compatibility/features/attachments/attachments.ts index e84bb71a8..4d130baa4 100644 --- a/compatibility/features/attachments/attachments.ts +++ b/compatibility/features/attachments/attachments.ts @@ -63,9 +63,26 @@ When('a JPEG image is attached', async function (this: World) { 'compatibility-kit', 'features', 'attachments', - 'cucumber-growing-on-vine.jpg' + 'cucumber.png' ) ), - 'image/jpg' + 'image/png' + ) +}) + +When('the {word} png is attached', async function (filename) { + await this.attach( + fs.createReadStream( + path.join( + process.cwd(), + 'node_modules', + '@cucumber', + 'compatibility-kit', + 'features', + 'attachments', + filename + ) + ), + 'image/png' ) }) diff --git a/compatibility/features/retry/retry.ts b/compatibility/features/retry/retry.ts new file mode 100644 index 000000000..888982124 --- /dev/null +++ b/compatibility/features/retry/retry.ts @@ -0,0 +1,25 @@ +import { Given } from '../../../src' + +Given('a step that always passes', function () { + // no-op +}) + +let secondTimePass = 0 +Given('a step that passes the second time', function () { + secondTimePass++ + if (secondTimePass < 2) { + throw new Error('Exception in step') + } +}) + +let thirdTimePass = 0 +Given('a step that passes the third time', function () { + thirdTimePass++ + if (thirdTimePass < 3) { + throw new Error('Exception in step') + } +}) + +Given('a step that always fails', function () { + throw new Error('Exception in step') +}) diff --git a/docs/migration.md b/docs/migration.md index 36ee13f82..726cbb01d 100644 --- a/docs/migration.md +++ b/docs/migration.md @@ -61,8 +61,7 @@ Now in `@cucumber/cucumber`: "duration": { "seconds": "0", "nanos": 660000000 - }, - "willBeRetried": true + } } } ``` diff --git a/features/fixtures/formatters/failed.message.json.ts b/features/fixtures/formatters/failed.message.json.ts index b9438c3f1..11cef7318 100644 --- a/features/fixtures/formatters/failed.message.json.ts +++ b/features/fixtures/formatters/failed.message.json.ts @@ -139,7 +139,6 @@ module.exports = [ nanos: 0, }, status: 'FAILED', - willBeRetried: false, message: 'Error: my error', }, timestamp: { @@ -155,6 +154,7 @@ module.exports = [ seconds: 0, nanos: 4000000, }, + willBeRetried: false, }, }, { diff --git a/features/fixtures/formatters/passed-rule.message.json.ts b/features/fixtures/formatters/passed-rule.message.json.ts index 784f4eba1..98210b60b 100644 --- a/features/fixtures/formatters/passed-rule.message.json.ts +++ b/features/fixtures/formatters/passed-rule.message.json.ts @@ -154,7 +154,6 @@ module.exports = [ nanos: 0, }, status: 'PASSED', - willBeRetried: false, }, timestamp: { seconds: 0, @@ -169,6 +168,7 @@ module.exports = [ seconds: 0, nanos: 4000000, }, + willBeRetried: false, }, }, { diff --git a/features/fixtures/formatters/passed-scenario.message.json.ts b/features/fixtures/formatters/passed-scenario.message.json.ts index 99a403fd7..856dc5f32 100644 --- a/features/fixtures/formatters/passed-scenario.message.json.ts +++ b/features/fixtures/formatters/passed-scenario.message.json.ts @@ -139,7 +139,6 @@ module.exports = [ nanos: 0, }, status: 'PASSED', - willBeRetried: false, }, timestamp: { seconds: 0, @@ -154,6 +153,7 @@ module.exports = [ seconds: 0, nanos: 4000000, }, + willBeRetried: false, }, }, { diff --git a/features/fixtures/formatters/retried.message.json.ts b/features/fixtures/formatters/retried.message.json.ts index 1d82e730c..cc8615094 100644 --- a/features/fixtures/formatters/retried.message.json.ts +++ b/features/fixtures/formatters/retried.message.json.ts @@ -139,7 +139,6 @@ module.exports = [ nanos: 0, }, status: 'FAILED', - willBeRetried: true, message: 'Error: my error', }, timestamp: { @@ -155,6 +154,7 @@ module.exports = [ seconds: 0, nanos: 4000000, }, + willBeRetried: true, }, }, { @@ -188,7 +188,6 @@ module.exports = [ nanos: 0, }, status: 'PASSED', - willBeRetried: false, }, timestamp: { seconds: 0, @@ -203,6 +202,7 @@ module.exports = [ seconds: 0, nanos: 8000000, }, + willBeRetried: false, }, }, { diff --git a/package-lock.json b/package-lock.json index 6a6651cfe..487ae9e68 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,13 +9,13 @@ "version": "7.3.0", "license": "MIT", "dependencies": { - "@cucumber/create-meta": "^5.0.0", - "@cucumber/cucumber-expressions": "^12.1.1", - "@cucumber/gherkin": "^19.0.3", - "@cucumber/gherkin-streams": "^2.0.2", - "@cucumber/html-formatter": "^15.0.2", - "@cucumber/messages": "^16.0.1", - "@cucumber/tag-expressions": "^3.0.1", + "@cucumber/create-meta": "6.0.1", + "@cucumber/cucumber-expressions": "12.1.2", + "@cucumber/gherkin": "20.0.1", + "@cucumber/gherkin-streams": "3.0.0", + "@cucumber/html-formatter": "16.0.1", + "@cucumber/messages": "17.0.1", + "@cucumber/tag-expressions": "3.0.1", "assertion-error-formatter": "^3.0.0", "capital-case": "^1.0.4", "cli-table3": "^0.6.0", @@ -43,9 +43,9 @@ "cucumber-js": "bin/cucumber-js" }, "devDependencies": { - "@cucumber/compatibility-kit": "7.0.0", - "@cucumber/message-streams": "2.1.0", - "@cucumber/query": "10.1.0", + "@cucumber/compatibility-kit": "7.1.0", + "@cucumber/message-streams": "3.0.0", + "@cucumber/query": "11.0.0", "@sinonjs/fake-timers": "7.1.2", "@types/chai": "4.2.21", "@types/dirty-chai": "2.0.2", @@ -533,106 +533,90 @@ } }, "node_modules/@cucumber/compatibility-kit": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@cucumber/compatibility-kit/-/compatibility-kit-7.0.0.tgz", - "integrity": "sha512-RmRaednTus8Pl1rjOqdNeXp2TUWCfkQhvP0Eq9DW5gwubnFgJlKd9kHyY+VO8/te+Vv8a9YAyXeZ0SJy7QnRLA==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@cucumber/compatibility-kit/-/compatibility-kit-7.1.0.tgz", + "integrity": "sha512-9XK8Fbbkg6Dpbvb96KpRozGtMXbfy266jV+bh95/X697eXDoOlTe5OBcZjzpti3l40Ksu2NpF0fE0YvXMPixVw==", "dev": true }, "node_modules/@cucumber/create-meta": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@cucumber/create-meta/-/create-meta-5.0.0.tgz", - "integrity": "sha512-Z5kMZkUff00S3/KSnKzB/KOm2UIxMXY1xXmj2dQMlD49lV6v/W8EEvgDMNtQotQNSOQU5bDupmWQpk+o16tXIw==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/create-meta/-/create-meta-6.0.1.tgz", + "integrity": "sha512-oaNFVBAfduO0GJ1xUtgfGZHvg6+CH56DYaGWPAraayLxvtsQwaOnBYMzzaccGHty/Q6sksQ+IIZK3SuGkTmdvg==", "dependencies": { - "@cucumber/messages": "^16.0.0" + "@cucumber/messages": "^17.0.1" } }, "node_modules/@cucumber/cucumber-expressions": { - "version": "12.1.1", - "resolved": "https://registry.npmjs.org/@cucumber/cucumber-expressions/-/cucumber-expressions-12.1.1.tgz", - "integrity": "sha512-WKkQAW5A8mReAFbl6FwkSiTNsy478JAOrHROrzUqNDW7Q/FU3yvrvgueX7G0NHAkvMYUMLYTSaxqLFQIMJ+K3Q==", + "version": "12.1.2", + "resolved": "https://registry.npmjs.org/@cucumber/cucumber-expressions/-/cucumber-expressions-12.1.2.tgz", + "integrity": "sha512-3iSezyIpuc5NlEphh5gNiqGx4p9l+3n9qnhMbKP7ouJ1BjbTa7w+f8f5g13+n+i6TkJ08l+CtUrFXanoBbsxIQ==", "dependencies": { - "becke-ch--regex--s0-0-v1--base--pl--lib": "^1.4.0" + "becke-ch--regex--s0-0-v1--base--pl--lib": "1.4.0" } }, "node_modules/@cucumber/gherkin": { - "version": "19.0.3", - "resolved": "https://registry.npmjs.org/@cucumber/gherkin/-/gherkin-19.0.3.tgz", - "integrity": "sha512-gWdMm8mfRk3P+VugJWvNALaQV5QnT+5RkqWy3tO+4NsMSQZPo5p4V4vXwriQZ/sZR1Wni5TDRztuRsKLgZ3XHA==", + "version": "20.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/gherkin/-/gherkin-20.0.1.tgz", + "integrity": "sha512-1vXZETZYF3A9egC+N1EIeMobLQQ6VcQoGQ0NvHhkZ/NYXjJB+rPwMbZmhnDfqexhzJbWlA2CVNKc+VHrUobyyg==", "dependencies": { - "@cucumber/message-streams": "^2.0.0", - "@cucumber/messages": "^16.0.1" + "@cucumber/message-streams": "^3.0.0", + "@cucumber/messages": "^17.0.1" } }, "node_modules/@cucumber/gherkin-streams": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@cucumber/gherkin-streams/-/gherkin-streams-2.0.2.tgz", - "integrity": "sha512-cKmXOBz4OwGlrHMBCc4qCC3KzLaqcEZ11nWWskIbv6jyfvlIRuM2OgEF6VLcNVewczifW1p6DrDj0OO+BeXocA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@cucumber/gherkin-streams/-/gherkin-streams-3.0.0.tgz", + "integrity": "sha512-vdTfSJx4z3Ju2vtresEM930chq3DVxnuQ1FFCI69m2Q83sa2mL8VEFvJ5fwlF7fY/fqLwop04W6B7lCkSZq7fg==", "dependencies": { - "@cucumber/gherkin": "^19.0.1", - "@cucumber/message-streams": "^2.0.0", - "@cucumber/messages": "^16.0.0", - "commander": "7.2.0", + "@cucumber/gherkin": "^20.0.0", + "@cucumber/message-streams": "^3.0.0", + "@cucumber/messages": "^17.0.0", + "commander": "8.0.0", "source-map-support": "0.5.19" }, "bin": { "gherkin-javascript": "bin/gherkin" } }, - "node_modules/@cucumber/gherkin-streams/node_modules/commander": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", - "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", - "engines": { - "node": ">= 10" - } - }, "node_modules/@cucumber/html-formatter": { - "version": "15.0.2", - "resolved": "https://registry.npmjs.org/@cucumber/html-formatter/-/html-formatter-15.0.2.tgz", - "integrity": "sha512-j+YGY4ytj78G/v1gZo53D+vuKXlTg/oxNwSCCGvRQo75+AqYDJSkm/vexXJQ5lY1rXAvlbZ9KI6jhg6LDs0YdQ==", + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/html-formatter/-/html-formatter-16.0.1.tgz", + "integrity": "sha512-a/FPKreNILJWwjc/jXikqyLQRyGD6qY9XMSn5NdtJCXflzmPg3ihe9LMrR6DQTS1tr32kjuvsBdkv5lU80Xz6A==", "dependencies": { - "@cucumber/messages": "^16.0.1", - "commander": "7.2.0", + "@cucumber/messages": "^17.0.1", + "commander": "8.0.0", "source-map-support": "0.5.19" }, "bin": { "cucumber-html-formatter": "bin/cucumber-html-formatter.js" } }, - "node_modules/@cucumber/html-formatter/node_modules/commander": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", - "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", - "engines": { - "node": ">= 10" - } - }, "node_modules/@cucumber/message-streams": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@cucumber/message-streams/-/message-streams-2.1.0.tgz", - "integrity": "sha512-Yh3mw3qv6QL9NI/ihkZF8V9MX2GbnR6oktv34kC3uAbrQy9d/b2SZ3HNjG3J9JQqpV4B7Om3SPElJYIeo66TrA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@cucumber/message-streams/-/message-streams-3.0.0.tgz", + "integrity": "sha512-ABx91nKUebV8mLmpf7BsB3bmQ57CDAfj2EIZswThz+nJHYPAFlZ1JewI6ykFsR9RzJ7/QhgQs0KHeQh7nH/u1Q==", "dependencies": { - "@cucumber/messages": "^16.0.1" + "@cucumber/messages": "^17.0.0" } }, "node_modules/@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "version": "17.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-17.0.1.tgz", + "integrity": "sha512-cr07vBdiUnGgG3p2bUYhKswTwmk6yY62Fu/+Azvnd/eHar266+SkEs1UyO342ZXK56IyBtEE7T0X3Zn3V74q8A==", "dependencies": { - "@types/uuid": "8.3.0", + "@types/uuid": "8.3.1", "class-transformer": "0.4.0", "reflect-metadata": "0.1.13", "uuid": "8.3.2" } }, "node_modules/@cucumber/query": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/@cucumber/query/-/query-10.1.0.tgz", - "integrity": "sha512-6LzfJA62hqi8Nf3XGZjtLa1J8G5HrYNUMxWRcXxiGiOIq2erIaiWu8628NMmeIYLyf93LgiKHGcjNFTu7ZrTPA==", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@cucumber/query/-/query-11.0.0.tgz", + "integrity": "sha512-GkjZX7p8h4OiajDrBXs/4E7qKhnW5gsqVXvJRI1Vv7bREpXc1W0Gc9S4UDgtx/YQ6djs0yBrjIbSHJRtEHYnIA==", "dev": true, "dependencies": { - "@cucumber/messages": "^16.0.1", + "@cucumber/messages": "^17.0.0", "@teppeis/multimaps": "2.0.0" } }, @@ -1122,9 +1106,9 @@ "dev": true }, "node_modules/@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==" + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.1.tgz", + "integrity": "sha512-Y2mHTRAbqfFkpjldbkHGY8JIzRN6XqYRliG8/24FcHm2D2PwW24fl5xMRTVGdrb7iMrwCaIEbLWerGIkXuFWVg==" }, "node_modules/@types/verror": { "version": "1.10.5", @@ -7556,98 +7540,84 @@ } }, "@cucumber/compatibility-kit": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@cucumber/compatibility-kit/-/compatibility-kit-7.0.0.tgz", - "integrity": "sha512-RmRaednTus8Pl1rjOqdNeXp2TUWCfkQhvP0Eq9DW5gwubnFgJlKd9kHyY+VO8/te+Vv8a9YAyXeZ0SJy7QnRLA==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@cucumber/compatibility-kit/-/compatibility-kit-7.1.0.tgz", + "integrity": "sha512-9XK8Fbbkg6Dpbvb96KpRozGtMXbfy266jV+bh95/X697eXDoOlTe5OBcZjzpti3l40Ksu2NpF0fE0YvXMPixVw==", "dev": true }, "@cucumber/create-meta": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@cucumber/create-meta/-/create-meta-5.0.0.tgz", - "integrity": "sha512-Z5kMZkUff00S3/KSnKzB/KOm2UIxMXY1xXmj2dQMlD49lV6v/W8EEvgDMNtQotQNSOQU5bDupmWQpk+o16tXIw==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/create-meta/-/create-meta-6.0.1.tgz", + "integrity": "sha512-oaNFVBAfduO0GJ1xUtgfGZHvg6+CH56DYaGWPAraayLxvtsQwaOnBYMzzaccGHty/Q6sksQ+IIZK3SuGkTmdvg==", "requires": { - "@cucumber/messages": "^16.0.0" + "@cucumber/messages": "^17.0.1" } }, "@cucumber/cucumber-expressions": { - "version": "12.1.1", - "resolved": "https://registry.npmjs.org/@cucumber/cucumber-expressions/-/cucumber-expressions-12.1.1.tgz", - "integrity": "sha512-WKkQAW5A8mReAFbl6FwkSiTNsy478JAOrHROrzUqNDW7Q/FU3yvrvgueX7G0NHAkvMYUMLYTSaxqLFQIMJ+K3Q==", + "version": "12.1.2", + "resolved": "https://registry.npmjs.org/@cucumber/cucumber-expressions/-/cucumber-expressions-12.1.2.tgz", + "integrity": "sha512-3iSezyIpuc5NlEphh5gNiqGx4p9l+3n9qnhMbKP7ouJ1BjbTa7w+f8f5g13+n+i6TkJ08l+CtUrFXanoBbsxIQ==", "requires": { - "becke-ch--regex--s0-0-v1--base--pl--lib": "^1.4.0" + "becke-ch--regex--s0-0-v1--base--pl--lib": "1.4.0" } }, "@cucumber/gherkin": { - "version": "19.0.3", - "resolved": "https://registry.npmjs.org/@cucumber/gherkin/-/gherkin-19.0.3.tgz", - "integrity": "sha512-gWdMm8mfRk3P+VugJWvNALaQV5QnT+5RkqWy3tO+4NsMSQZPo5p4V4vXwriQZ/sZR1Wni5TDRztuRsKLgZ3XHA==", + "version": "20.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/gherkin/-/gherkin-20.0.1.tgz", + "integrity": "sha512-1vXZETZYF3A9egC+N1EIeMobLQQ6VcQoGQ0NvHhkZ/NYXjJB+rPwMbZmhnDfqexhzJbWlA2CVNKc+VHrUobyyg==", "requires": { - "@cucumber/message-streams": "^2.0.0", - "@cucumber/messages": "^16.0.1" + "@cucumber/message-streams": "^3.0.0", + "@cucumber/messages": "^17.0.1" } }, "@cucumber/gherkin-streams": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@cucumber/gherkin-streams/-/gherkin-streams-2.0.2.tgz", - "integrity": "sha512-cKmXOBz4OwGlrHMBCc4qCC3KzLaqcEZ11nWWskIbv6jyfvlIRuM2OgEF6VLcNVewczifW1p6DrDj0OO+BeXocA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@cucumber/gherkin-streams/-/gherkin-streams-3.0.0.tgz", + "integrity": "sha512-vdTfSJx4z3Ju2vtresEM930chq3DVxnuQ1FFCI69m2Q83sa2mL8VEFvJ5fwlF7fY/fqLwop04W6B7lCkSZq7fg==", "requires": { - "@cucumber/gherkin": "^19.0.1", - "@cucumber/message-streams": "^2.0.0", - "@cucumber/messages": "^16.0.0", - "commander": "7.2.0", + "@cucumber/gherkin": "^20.0.0", + "@cucumber/message-streams": "^3.0.0", + "@cucumber/messages": "^17.0.0", + "commander": "8.0.0", "source-map-support": "0.5.19" - }, - "dependencies": { - "commander": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", - "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==" - } } }, "@cucumber/html-formatter": { - "version": "15.0.2", - "resolved": "https://registry.npmjs.org/@cucumber/html-formatter/-/html-formatter-15.0.2.tgz", - "integrity": "sha512-j+YGY4ytj78G/v1gZo53D+vuKXlTg/oxNwSCCGvRQo75+AqYDJSkm/vexXJQ5lY1rXAvlbZ9KI6jhg6LDs0YdQ==", + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/html-formatter/-/html-formatter-16.0.1.tgz", + "integrity": "sha512-a/FPKreNILJWwjc/jXikqyLQRyGD6qY9XMSn5NdtJCXflzmPg3ihe9LMrR6DQTS1tr32kjuvsBdkv5lU80Xz6A==", "requires": { - "@cucumber/messages": "^16.0.1", - "commander": "7.2.0", + "@cucumber/messages": "^17.0.1", + "commander": "8.0.0", "source-map-support": "0.5.19" - }, - "dependencies": { - "commander": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", - "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==" - } } }, "@cucumber/message-streams": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@cucumber/message-streams/-/message-streams-2.1.0.tgz", - "integrity": "sha512-Yh3mw3qv6QL9NI/ihkZF8V9MX2GbnR6oktv34kC3uAbrQy9d/b2SZ3HNjG3J9JQqpV4B7Om3SPElJYIeo66TrA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@cucumber/message-streams/-/message-streams-3.0.0.tgz", + "integrity": "sha512-ABx91nKUebV8mLmpf7BsB3bmQ57CDAfj2EIZswThz+nJHYPAFlZ1JewI6ykFsR9RzJ7/QhgQs0KHeQh7nH/u1Q==", "requires": { - "@cucumber/messages": "^16.0.1" + "@cucumber/messages": "^17.0.0" } }, "@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "version": "17.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-17.0.1.tgz", + "integrity": "sha512-cr07vBdiUnGgG3p2bUYhKswTwmk6yY62Fu/+Azvnd/eHar266+SkEs1UyO342ZXK56IyBtEE7T0X3Zn3V74q8A==", "requires": { - "@types/uuid": "8.3.0", + "@types/uuid": "8.3.1", "class-transformer": "0.4.0", "reflect-metadata": "0.1.13", "uuid": "8.3.2" } }, "@cucumber/query": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/@cucumber/query/-/query-10.1.0.tgz", - "integrity": "sha512-6LzfJA62hqi8Nf3XGZjtLa1J8G5HrYNUMxWRcXxiGiOIq2erIaiWu8628NMmeIYLyf93LgiKHGcjNFTu7ZrTPA==", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@cucumber/query/-/query-11.0.0.tgz", + "integrity": "sha512-GkjZX7p8h4OiajDrBXs/4E7qKhnW5gsqVXvJRI1Vv7bREpXc1W0Gc9S4UDgtx/YQ6djs0yBrjIbSHJRtEHYnIA==", "dev": true, "requires": { - "@cucumber/messages": "^16.0.1", + "@cucumber/messages": "^17.0.0", "@teppeis/multimaps": "2.0.0" } }, @@ -8127,9 +8097,9 @@ "dev": true }, "@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==" + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.1.tgz", + "integrity": "sha512-Y2mHTRAbqfFkpjldbkHGY8JIzRN6XqYRliG8/24FcHm2D2PwW24fl5xMRTVGdrb7iMrwCaIEbLWerGIkXuFWVg==" }, "@types/verror": { "version": "1.10.5", diff --git a/package.json b/package.json index f10276859..a1c574820 100644 --- a/package.json +++ b/package.json @@ -168,13 +168,13 @@ "node": ">=12" }, "dependencies": { - "@cucumber/create-meta": "^5.0.0", - "@cucumber/cucumber-expressions": "^12.1.1", - "@cucumber/gherkin": "^19.0.3", - "@cucumber/gherkin-streams": "^2.0.2", - "@cucumber/html-formatter": "^15.0.2", - "@cucumber/messages": "^16.0.1", - "@cucumber/tag-expressions": "^3.0.1", + "@cucumber/create-meta": "6.0.1", + "@cucumber/cucumber-expressions": "12.1.2", + "@cucumber/gherkin": "20.0.1", + "@cucumber/gherkin-streams": "3.0.0", + "@cucumber/html-formatter": "16.0.1", + "@cucumber/messages": "17.0.1", + "@cucumber/tag-expressions": "3.0.1", "assertion-error-formatter": "^3.0.0", "capital-case": "^1.0.4", "cli-table3": "^0.6.0", @@ -199,9 +199,9 @@ "verror": "^1.10.0" }, "devDependencies": { - "@cucumber/compatibility-kit": "7.0.0", - "@cucumber/message-streams": "2.1.0", - "@cucumber/query": "10.1.0", + "@cucumber/compatibility-kit": "7.1.0", + "@cucumber/message-streams": "3.0.0", + "@cucumber/query": "11.0.0", "@sinonjs/fake-timers": "7.1.2", "@types/chai": "4.2.21", "@types/dirty-chai": "2.0.2", diff --git a/src/formatter/helpers/event_data_collector.ts b/src/formatter/helpers/event_data_collector.ts index f7af475a7..d976d1417 100644 --- a/src/formatter/helpers/event_data_collector.ts +++ b/src/formatter/helpers/event_data_collector.ts @@ -4,6 +4,7 @@ import { EventEmitter } from 'events' interface ITestCaseAttemptData { attempt: number + willBeRetried: boolean testCaseId: string stepAttachments: Record stepResults: Record @@ -12,6 +13,7 @@ interface ITestCaseAttemptData { export interface ITestCaseAttempt { attempt: number + willBeRetried: boolean gherkinDocument: messages.GherkinDocument pickle: messages.Pickle stepAttachments: Record @@ -54,6 +56,7 @@ export default class EventDataCollector { pickle, testCase, attempt: testCaseAttemptData.attempt, + willBeRetried: testCaseAttemptData.willBeRetried, stepAttachments: testCaseAttemptData.stepAttachments, stepResults: testCaseAttemptData.stepResults, worstTestStepResult: testCaseAttemptData.worstTestStepResult, @@ -84,11 +87,11 @@ export default class EventDataCollector { private initTestCaseAttempt(testCaseStarted: messages.TestCaseStarted): void { this.testCaseAttemptDataMap[testCaseStarted.id] = { attempt: testCaseStarted.attempt, + willBeRetried: false, testCaseId: testCaseStarted.testCaseId, stepAttachments: {}, stepResults: {}, worstTestStepResult: { - willBeRetried: false, duration: { seconds: 0, nanos: 0 }, status: messages.TestStepResultStatus.UNKNOWN, }, @@ -116,11 +119,15 @@ export default class EventDataCollector { testStepResult } - storeTestCaseResult({ testCaseStartedId }: messages.TestCaseFinished): void { + storeTestCaseResult({ + testCaseStartedId, + willBeRetried, + }: messages.TestCaseFinished): void { const stepResults = Object.values( this.testCaseAttemptDataMap[testCaseStartedId].stepResults ) this.testCaseAttemptDataMap[testCaseStartedId].worstTestStepResult = messages.getWorstTestStepResult(stepResults) + this.testCaseAttemptDataMap[testCaseStartedId].willBeRetried = willBeRetried } } diff --git a/src/formatter/helpers/issue_helpers.ts b/src/formatter/helpers/issue_helpers.ts index a2ae756fd..02fa6f419 100644 --- a/src/formatter/helpers/issue_helpers.ts +++ b/src/formatter/helpers/issue_helpers.ts @@ -6,18 +6,23 @@ import StepDefinitionSnippetBuilder from '../step_definition_snippet_builder' import { ISupportCodeLibrary } from '../../support_code_library_builder/types' import { ITestCaseAttempt } from './event_data_collector' -export function isFailure(result: messages.TestStepResult): boolean { +export function isFailure( + result: messages.TestStepResult, + willBeRetried: boolean = false +): boolean { return ( result.status === 'AMBIGUOUS' || result.status === 'UNDEFINED' || - (result.status === 'FAILED' && !result.willBeRetried) + (result.status === 'FAILED' && !willBeRetried) ) } -export function isWarning(result: messages.TestStepResult): boolean { +export function isWarning( + result: messages.TestStepResult, + willBeRetried: boolean = false +): boolean { return ( - result.status === 'PENDING' || - (result.status === 'FAILED' && result.willBeRetried) + result.status === 'PENDING' || (result.status === 'FAILED' && willBeRetried) ) } diff --git a/src/formatter/helpers/summary_helpers.ts b/src/formatter/helpers/summary_helpers.ts index f7e77902b..e18bfb9d9 100644 --- a/src/formatter/helpers/summary_helpers.ts +++ b/src/formatter/helpers/summary_helpers.ts @@ -27,22 +27,24 @@ export function formatSummary({ const testCaseResults: messages.TestStepResult[] = [] const testStepResults: messages.TestStepResult[] = [] let totalStepDuration = messages.TimeConversion.millisecondsToDuration(0) - testCaseAttempts.forEach(({ testCase, worstTestStepResult, stepResults }) => { - Object.values(stepResults).forEach((stepResult) => { - totalStepDuration = messages.TimeConversion.addDurations( - totalStepDuration, - stepResult.duration - ) - }) - if (!worstTestStepResult.willBeRetried) { - testCaseResults.push(worstTestStepResult) - testCase.testSteps.forEach((testStep) => { - if (doesHaveValue(testStep.pickleStepId)) { - testStepResults.push(stepResults[testStep.id]) - } + testCaseAttempts.forEach( + ({ testCase, willBeRetried, worstTestStepResult, stepResults }) => { + Object.values(stepResults).forEach((stepResult) => { + totalStepDuration = messages.TimeConversion.addDurations( + totalStepDuration, + stepResult.duration + ) }) + if (!willBeRetried) { + testCaseResults.push(worstTestStepResult) + testCase.testSteps.forEach((testStep) => { + if (doesHaveValue(testStep.pickleStepId)) { + testStepResults.push(stepResults[testStep.id]) + } + }) + } } - }) + ) const scenarioSummary = getCountSummary({ colorFns, objects: testCaseResults, diff --git a/src/formatter/helpers/test_case_attempt_formatter.ts b/src/formatter/helpers/test_case_attempt_formatter.ts index bc1319644..3c67c3cb0 100644 --- a/src/formatter/helpers/test_case_attempt_formatter.ts +++ b/src/formatter/helpers/test_case_attempt_formatter.ts @@ -92,10 +92,7 @@ export function formatTestCaseAttempt({ supportCodeLibrary, }) let text = `Scenario: ${parsed.testCase.name}` - text += getAttemptText( - parsed.testCase.attempt, - parsed.testCase.worstTestStepResult.willBeRetried - ) + text += getAttemptText(parsed.testCase.attempt, testCaseAttempt.willBeRetried) text += ` # ${colorFns.location( formatLocation(parsed.testCase.sourceLocation) )}\n` diff --git a/src/formatter/json_formatter.ts b/src/formatter/json_formatter.ts index ff3c82ace..2b2c21c33 100644 --- a/src/formatter/json_formatter.ts +++ b/src/formatter/json_formatter.ts @@ -132,7 +132,7 @@ export default class JsonFormatter extends Formatter { this.eventDataCollector .getTestCaseAttempts() .forEach((testCaseAttempt: ITestCaseAttempt) => { - if (!testCaseAttempt.worstTestStepResult.willBeRetried) { + if (!testCaseAttempt.willBeRetried) { const uri = testCaseAttempt.pickle.uri if (doesNotHaveValue(groupedTestCaseAttempts[uri])) { groupedTestCaseAttempts[uri] = [] diff --git a/src/formatter/progress_bar_formatter.ts b/src/formatter/progress_bar_formatter.ts index 2456ec93c..ed6fc812d 100644 --- a/src/formatter/progress_bar_formatter.ts +++ b/src/formatter/progress_bar_formatter.ts @@ -80,7 +80,7 @@ export default class ProgressBarFormatter extends Formatter { testCaseAttempt, }) ) - if (worstTestStepResult.willBeRetried) { + if (testCaseFinished.willBeRetried) { const stepsToRetry = testCaseAttempt.pickle.steps.length this.progressBar.tick(-stepsToRetry) } diff --git a/src/formatter/summary_formatter.ts b/src/formatter/summary_formatter.ts index d66c32aad..e49e342a7 100644 --- a/src/formatter/summary_formatter.ts +++ b/src/formatter/summary_formatter.ts @@ -36,9 +36,19 @@ export default class SummaryFormatter extends Formatter { const warnings: ITestCaseAttempt[] = [] const testCaseAttempts = this.eventDataCollector.getTestCaseAttempts() testCaseAttempts.forEach((testCaseAttempt) => { - if (isFailure(testCaseAttempt.worstTestStepResult)) { + if ( + isFailure( + testCaseAttempt.worstTestStepResult, + testCaseAttempt.willBeRetried + ) + ) { failures.push(testCaseAttempt) - } else if (isWarning(testCaseAttempt.worstTestStepResult)) { + } else if ( + isWarning( + testCaseAttempt.worstTestStepResult, + testCaseAttempt.willBeRetried + ) + ) { warnings.push(testCaseAttempt) } }) diff --git a/src/runtime/parallel/coordinator.ts b/src/runtime/parallel/coordinator.ts index 7c5b518c1..d78cd08c4 100644 --- a/src/runtime/parallel/coordinator.ts +++ b/src/runtime/parallel/coordinator.ts @@ -162,7 +162,7 @@ export default class Coordinator { testCaseFinished.testCaseStartedId ) if ( - !worstTestStepResult.willBeRetried && + !testCaseFinished.willBeRetried && this.shouldCauseFailure(worstTestStepResult.status) ) { this.success = false diff --git a/src/runtime/step_runner.ts b/src/runtime/step_runner.ts index e00a0f20b..14e765bfd 100644 --- a/src/runtime/step_runner.ts +++ b/src/runtime/step_runner.ts @@ -78,7 +78,6 @@ export async function run({ duration, status, message, - willBeRetried: false, } } diff --git a/src/runtime/test_case_runner.ts b/src/runtime/test_case_runner.ts index e5a910a24..308e04c22 100644 --- a/src/runtime/test_case_runner.ts +++ b/src/runtime/test_case_runner.ts @@ -1,8 +1,8 @@ import { getAmbiguousStepException } from './helpers' import AttachmentManager from './attachment_manager' import StepRunner from './step_runner' -import { IdGenerator, getWorstTestStepResult } from '@cucumber/messages' import * as messages from '@cucumber/messages' +import { getWorstTestStepResult, IdGenerator } from '@cucumber/messages' import { EventEmitter } from 'events' import { ISupportCodeLibrary, @@ -116,7 +116,6 @@ export default class TestCaseRunner { status: this.skip ? messages.TestStepResultStatus.SKIPPED : messages.TestStepResultStatus.PASSED, - willBeRetried: false, duration: messages.TimeConversion.millisecondsToDuration(0), } } @@ -149,7 +148,6 @@ export default class TestCaseRunner { async aroundTestStep( testStepId: string, - attempt: number, runStepFn: () => Promise ): Promise { const testStepStarted: messages.Envelope = { @@ -164,16 +162,6 @@ export default class TestCaseRunner { const testStepResult = await runStepFn() this.currentTestStepId = null this.testStepResults.push(testStepResult) - if ( - testStepResult.status === messages.TestStepResultStatus.FAILED && - attempt + 1 < this.maxAttempts - ) { - /* - TODO dont rely on `testStepResult.willBeRetried`, it will be moved or removed - see https://github.com/cucumber/cucumber/issues/902 - */ - testStepResult.willBeRetried = true - } const testStepFinished: messages.Envelope = { testStepFinished: { testCaseStartedId: this.currentTestCaseStartedId, @@ -200,7 +188,7 @@ export default class TestCaseRunner { // used to determine whether a hook is a Before or After let didWeRunStepsYet = false for (const testStep of this.testCase.testSteps) { - await this.aroundTestStep(testStep.id, attempt, async () => { + await this.aroundTestStep(testStep.id, async () => { if (doesHaveValue(testStep.hookId)) { const hookParameter: ITestCaseHookParameter = { gherkinDocument: this.gherkinDocument, @@ -225,14 +213,18 @@ export default class TestCaseRunner { } }) } + const willBeRetried = + this.getWorstStepResult().status === + messages.TestStepResultStatus.FAILED && attempt + 1 < this.maxAttempts const testCaseFinished: messages.Envelope = { testCaseFinished: { testCaseStartedId: this.currentTestCaseStartedId, timestamp: this.stopwatch.timestamp(), + willBeRetried, }, } this.eventBroadcaster.emit('envelope', testCaseFinished) - if (!this.getWorstStepResult().willBeRetried) { + if (!willBeRetried) { break } this.resetTestProgressData() @@ -249,7 +241,6 @@ export default class TestCaseRunner { return { status: messages.TestStepResultStatus.SKIPPED, duration: messages.TimeConversion.millisecondsToDuration(0), - willBeRetried: false, } } return await this.invokeStep(null, hookDefinition, hookParameter) @@ -288,20 +279,17 @@ export default class TestCaseRunner { return { status: messages.TestStepResultStatus.UNDEFINED, duration: messages.TimeConversion.millisecondsToDuration(0), - willBeRetried: false, } } else if (stepDefinitions.length > 1) { return { message: getAmbiguousStepException(stepDefinitions), status: messages.TestStepResultStatus.AMBIGUOUS, duration: messages.TimeConversion.millisecondsToDuration(0), - willBeRetried: false, } } else if (this.isSkippingSteps()) { return { status: messages.TestStepResultStatus.SKIPPED, duration: messages.TimeConversion.millisecondsToDuration(0), - willBeRetried: false, } } diff --git a/src/runtime/test_case_runner_spec.ts b/src/runtime/test_case_runner_spec.ts index 9e69b25f8..76ad1c77b 100644 --- a/src/runtime/test_case_runner_spec.ts +++ b/src/runtime/test_case_runner_spec.ts @@ -99,7 +99,6 @@ describe('TestCaseRunner', () => { duration: messages.TimeConversion.millisecondsToDuration(1), status: messages.TestStepResultStatus.PASSED, message: undefined, - willBeRetried: false, } // Act @@ -110,7 +109,7 @@ describe('TestCaseRunner', () => { }) // Assert - const expectedtEnvelopes = [ + const expectedtEnvelopes: messages.Envelope[] = [ { testCaseStarted: { attempt: 0, @@ -138,6 +137,7 @@ describe('TestCaseRunner', () => { testCaseFinished: { testCaseStartedId: '2', timestamp: predictableTimestamp(3), + willBeRetried: false, }, }, ] @@ -165,7 +165,6 @@ describe('TestCaseRunner', () => { duration: messages.TimeConversion.millisecondsToDuration(0), status: messages.TestStepResultStatus.FAILED, message: 'fail', - willBeRetried: false, } // Act @@ -216,7 +215,6 @@ describe('TestCaseRunner', () => { message, status: messages.TestStepResultStatus.AMBIGUOUS, duration: messages.TimeConversion.millisecondsToDuration(0), - willBeRetried: false, } expect(envelopes[2].testStepFinished.testStepResult).to.eql(expected) expect(result).to.eql( @@ -249,7 +247,6 @@ describe('TestCaseRunner', () => { const expected: messages.TestStepResult = { status: messages.TestStepResultStatus.UNDEFINED, duration: messages.TimeConversion.millisecondsToDuration(0), - willBeRetried: false, } expect(envelopes[2].testStepFinished.testStepResult).to.eql(expected) expect(result).to.eql( @@ -311,7 +308,6 @@ describe('TestCaseRunner', () => { duration: messages.TimeConversion.millisecondsToDuration(0), message: 'error', status: messages.TestStepResultStatus.FAILED, - willBeRetried: true, }, testStepId: '1', timestamp: predictableTimestamp(2), @@ -321,6 +317,7 @@ describe('TestCaseRunner', () => { testCaseFinished: { testCaseStartedId: '2', timestamp: predictableTimestamp(3), + willBeRetried: true, }, }, { @@ -345,7 +342,6 @@ describe('TestCaseRunner', () => { duration: messages.TimeConversion.millisecondsToDuration(0), message: undefined, status: messages.TestStepResultStatus.PASSED, - willBeRetried: false, }, testStepId: '1', timestamp: predictableTimestamp(6), @@ -355,6 +351,7 @@ describe('TestCaseRunner', () => { testCaseFinished: { testCaseStartedId: '3', timestamp: predictableTimestamp(7), + willBeRetried: false, }, }, ] @@ -392,7 +389,6 @@ describe('TestCaseRunner', () => { const expected: messages.TestStepResult = { status: messages.TestStepResultStatus.SKIPPED, duration: messages.TimeConversion.millisecondsToDuration(0), - willBeRetried: false, } expect(envelopes[2].testStepFinished.testStepResult).to.eql(expected) expect(result).to.eql(