Skip to content

Commit

Permalink
improvement: set scenario timeout via test.setTimeout instead of anon…
Browse files Browse the repository at this point in the history
…ymous describe (#139)
  • Loading branch information
vitalets committed Apr 19, 2024
1 parent d171cac commit 73def2f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## dev
* improvement: set scenario timeout via `test.setTimeout` instead of anonymous describe ([#139](https://github.com/vitalets/playwright-bdd/issues/139))
* feature: add `@slow` special tag ([#138](https://github.com/vitalets/playwright-bdd/issues/138))
* improvement: relax rules for guessing fixtures in decorator steps, introduce new config option `statefulPoms` for more strict checks ([#102](https://github.com/vitalets/playwright-bdd/issues/102))

Expand Down
9 changes: 5 additions & 4 deletions src/gen/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,18 @@ export class Formatter {
if (!children.length) return [`${firstLine}});`, ''];
const lines = [
firstLine, // prettier-ignore
...this.testTimeout(node).map(indent),
...this.markAsSlow(node).map(indent),
...this.markAsFailed(node).map(indent),
...children.map(indent),
`});`,
'',
];
// wrap test into anonymous describe in case of retries / timeout tags
const specialTagsConfigure = this.describeConfigure(node);
return specialTagsConfigure.length
// Wrap test into anonymous describe in case of retries
// See: https://github.com/microsoft/playwright/issues/10825
return node.specialTags.retries
? this.wrapInAnonymousDescribe([
...specialTagsConfigure.map(indent),
...this.describeConfigure(node).map(indent),
'',
...lines.map(indent),
])
Expand Down
4 changes: 4 additions & 0 deletions test/special-tags/features/timeout.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ Feature: timeout tag
Scenario Outline: scenario 2
Given success step <start>

@timeout:2000
Examples:
| start |
| 2 |

Examples:
| start |
| 3 |
4 changes: 2 additions & 2 deletions test/special-tags/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ function checkRetriesTag() {
function checkTimeoutTag() {
testDir.expectFileContains(`.features-gen/timeout.feature.spec.js`, [
`${' '.repeat(2)}test.describe.configure({"timeout":5000});`,
`${' '.repeat(2)}test.describe(() => {`,
`${' '.repeat(4)}test.describe.configure({"timeout":4000});`,
`${' '.repeat(4)}test.setTimeout(4000);`,
`${' '.repeat(4)}test.describe.configure({"timeout":3000});`,
`${' '.repeat(6)}test.setTimeout(2000);`,
]);
}

Expand Down

0 comments on commit 73def2f

Please sign in to comment.