diff --git a/.changeset/ten-snails-buy.md b/.changeset/ten-snails-buy.md index cf9c760..38170b1 100644 --- a/.changeset/ten-snails-buy.md +++ b/.changeset/ten-snails-buy.md @@ -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() diff --git a/README.md b/README.md index 57c8802..1980424 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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() diff --git a/lib/index.ts b/lib/index.ts index f32040f..d70812e 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -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' diff --git a/lib/retry.decorator.ts b/lib/retries.decorator.ts similarity index 89% rename from lib/retry.decorator.ts rename to lib/retries.decorator.ts index 08912f8..7e79c9b 100644 --- a/lib/retry.decorator.ts +++ b/lib/retries.decorator.ts @@ -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 }) diff --git a/tests/retry.spec.ts b/tests/retries.spec.ts similarity index 62% rename from tests/retry.spec.ts rename to tests/retries.spec.ts index 3daa0b4..5da775b 100644 --- a/tests/retry.spec.ts +++ b/tests/retries.spec.ts @@ -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) {