-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add `@retry` decorator * chore: add changesets * docs: fix typos * refactor: rename `retry` decorator to `retries` * refactor: rename `retry` decorator to `retries`
- Loading branch information
1 parent
86ff2f5
commit 2962b6e
Showing
6 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
"playwright-decorators": minor | ||
--- | ||
|
||
Add `@retries` decorator | ||
|
||
Set the maximum number of retry attempts given to failed `@tests` in the `@suite` | ||
|
||
```ts | ||
import { suite, test, retries } from 'playwright-decorators'; | ||
|
||
@retries(3) // <-- Decorate suite with @retries() | ||
@suite() | ||
class MyTestSuite { | ||
@test() | ||
async test() { // <- This test may be retried up to 3 times if it fails | ||
// ... | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import playwright from '@playwright/test' | ||
import { createSuiteDecorator } from '../lib' | ||
|
||
/** | ||
* Set the maximum number of retry attempts given to failed @tests in the @suite | ||
* @param retries the number of retries for each @test. | ||
*/ | ||
export const retries = (retries: number) => | ||
createSuiteDecorator('retry', ({ suite }) => { | ||
suite.initialized(() => { | ||
playwright.describe.configure({ retries }) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { suite, test, retries, TestInfo } from '../lib' | ||
import playwright, { expect } from '@playwright/test' | ||
|
||
playwright.describe('@retries decorator', () => { | ||
@retries(3) | ||
@suite() | ||
class RetriesSuite { | ||
@test() | ||
// eslint-disable-next-line no-empty-pattern | ||
'Should retry test 3 times'({}, testInfo: TestInfo) { | ||
expect(testInfo.retry + 1).toEqual(3) | ||
} | ||
} | ||
}) |