Skip to content

Commit

Permalink
refactor: rename retry decorator to retries
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianSedzik committed Jan 31, 2024
1 parent f9bbebf commit bb6c9f8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .changeset/ten-snails-buy.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Add `@retry` decorator
Set the maximum number of retry attempts given to failed `@tests` in the `@suite`

```ts
import { suite, test, retry } from 'playwright-decorators';
import { suite, test, retries } from 'playwright-decorators';

@retry(3) // <-- Decorate suite with @retry()
@retries(3) // <-- Decorate suite with @retries()
@suite()
class MyTestSuite {
@test()
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class MyTestSuite {
- [Run only selected test(s) or suite(s): `@only`](#run-only-selected-tests-or-suites-only)
- [Run test(s) or suite(s) with certain tag(s): `@tag`](#run-tests-or-suites-with-certain-tags-tagtags-string)
- [Add custom annotation to test(s): `@annotate`](#add-custom-annotation-to-tests-annotatetype-string-description-string)
- [Retry test(s): `@retry`](#retry-tests-retries-number)
- [Change or set retries for test(s): `@retries`](#change-or-set-retries-for-tests-retriesretries-number)
- [Run test(s) or suite(s) in debug mode: `@debug`](#run-tests-or-suites-in-debug-mode-debug)
- [Run test(s) or suite(s) in preview mode: `@preview`](#run-tests-or-suites-in-preview-mode-preview)
- [Create custom decorator: `createSuiteDecorator`, `createTestDecorator`, `createSuiteAndTestDecorator`](#custom-decorators)
Expand Down Expand Up @@ -367,13 +367,13 @@ class MyTestSuite {
- `type` (required) - type of annotation, for example 'skip' or 'fail'.
- `description` (optional) - description of annotation.

### Retry test(s): `@retry(retries: number)`
### Change or set retries for test(s): `@retries(retries: number)`
Set the maximum number of retry attempts given to failed `@tests` in the `@suite`

```ts
import { suite, test, retry } from 'playwright-decorators';
import { suite, test, retries } from 'playwright-decorators';

@retry(3) // <-- Decorate suite with @retry()
@retries(3) // <-- Decorate suite with @retries()
@suite()
class MyTestSuite {
@test()
Expand Down
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export { fixme } from './fixme.decorator'
export { only } from './only.decorator'
export { annotation } from './annotation.decorator'
export { tag } from './tag.decorator'
export { retry } from './retry.decorator'
export { retries } from './retries.decorator'

// helpers
export { debug } from './debug.decorator'
Expand Down
2 changes: 1 addition & 1 deletion lib/retry.decorator.ts → lib/retries.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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 retry = (retries: number) =>
export const retries = (retries: number) =>
createSuiteDecorator('retry', ({ suite }) => {
suite.initialized(() => {
playwright.describe.configure({ retries })
Expand Down
8 changes: 4 additions & 4 deletions tests/retry.spec.ts → tests/retries.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { suite, test, retry, TestInfo } from '../lib'
import { suite, test, retries, TestInfo } from '../lib'
import playwright, { expect } from '@playwright/test'

playwright.describe('@skip decorator', () => {
@retry(3)
playwright.describe('@retries decorator', () => {
@retries(3)
@suite()
class RetrySuite {
class RetriesSuite {
@test()
// eslint-disable-next-line no-empty-pattern
'Should retry test 3 times'({}, testInfo: TestInfo) {
Expand Down

0 comments on commit bb6c9f8

Please sign in to comment.