diff --git a/.changeset/great-doors-greet.md b/.changeset/great-doors-greet.md new file mode 100644 index 0000000..fa0ef38 --- /dev/null +++ b/.changeset/great-doors-greet.md @@ -0,0 +1,18 @@ +--- +'playwright-decorators': patch +--- + +Fix export of `TestInfo` type + +```ts +import { suite, test, TestArgs, TestInfo } from '@playwright/test' + +@suite() +class TestSuite { + @test() + myTest({ page }: TestArgs, testInfo: TestInfo) { + // ... + } +} + +``` diff --git a/.changeset/red-beans-exercise.md b/.changeset/red-beans-exercise.md new file mode 100644 index 0000000..7ddc9ac --- /dev/null +++ b/.changeset/red-beans-exercise.md @@ -0,0 +1,31 @@ +--- +'playwright-decorators': minor +--- + +Added support for creating custom test and suite decorator + +```ts +import { createSuiteAndTestDecorator } from 'playwright-decorators' +import playwright from '@playwright/test' + +const mySuiteAndTestDecorator = createSuiteAndTestDecorator( + 'mySuiteAndTestDecorator', + ({suite}) => { + suite.initialized(() => { + /** run custom code when suite is initialized **/ + }) + }, + ({test}) => { + test.beforeTest(() => { + /** run custom code before test execution **/ + }) + test.afterTest(() => { + /** run custom code after test execution **/ + }) + + playwright.beforeEach(() => { + /** run custom code before each test execution **/ + }) + } +); +``` diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 5ad2236..abf828e 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -39,7 +39,7 @@ jobs: uses: actions/checkout@v4 - name: Prepare uses: ./.github/actions/prepare - - name: Build + - name: Test run: | npx playwright install chromium npm run test diff --git a/README.md b/README.md index e95e54f..eeae62c 100644 --- a/README.md +++ b/README.md @@ -348,7 +348,7 @@ Attempting to utilize a custom test decorator on a method that lacks the `@test` import { suite, createTestDecorator } from 'playwright-decorators'; import playwright from '@playwright/test'; -const customTestDecorator = createTestDecorator('customTestDecorator', ({ test, context }) => { +const customTestDecorator = createTestDecorator('customTestDecorator', ({ test }) => { // create code using hooks provided by test decorator... test.beforeTest(() => { /* ... */ }) test.afterTest(() => { /* ... */ }) @@ -379,8 +379,12 @@ Attempting to apply a custom suite decorator to a class that lacks the `@suite` ```ts import { suite, createSuiteDecorator } from 'playwright-decorators'; -const customSuiteDecorator = createSuiteDecorator('customSuiteDecorator', ({ suite, context }) => { - // ... +const customSuiteDecorator = createSuiteDecorator('customSuiteDecorator', ({ suite }) => { + // run your custom code imadiately + suite.name = 'Custom name'; + + // or attach to specific hooks... + suite.initialized(() => { /* ... */ }) }); ``` @@ -392,3 +396,20 @@ class MyTestSuite { // ... } ``` + +### Suite and test decorator +The `createSuiteAndTestDecorator` function allows the creation of custom decorators that can be applied to both suites and tests. + +```ts +import {createSuiteAndTestDecorator} from 'playwright-decorators'; + +const customSuiteAndTestDecorator = createSuiteAndTestDecorator( + 'customSuiteAndTestDecorator', + ({ suite }) => { + // custom suite decorator code + }, + ({ test }) => { + // code test decorator code + } +) +``` diff --git a/examples/tests/decorators/withUser.ts b/examples/tests/decorators/withUser.ts index 3103c96..d35c059 100644 --- a/examples/tests/decorators/withUser.ts +++ b/examples/tests/decorators/withUser.ts @@ -6,29 +6,31 @@ import { createSuiteDecorator } from 'playwright-decorators' * Please use it with `@suite` decorator. */ export const withUser = (options: { features: string[] }) => - createSuiteDecorator('withUser', () => { - let testUser: { email: string; password: string } + createSuiteDecorator('withUser', ({ suite }) => { + suite.initialized(() => { + let testUser: { email: string; password: string } - // #1 Get test user credentials before all tests - playwright.beforeAll(async () => { - const testUserPayload = { features: options.features } + // #1 Get test user credentials before all tests + playwright.beforeAll(async () => { + const testUserPayload = { features: options.features } - // #2 Send request to create a new test user - const testUserData = await fetch('http://localhost:3000/create-user', { - method: 'POST', - body: JSON.stringify(testUserPayload), - headers: { 'Content-Type': 'application/json' } - }) + // #2 Send request to create a new test user + const testUserData = await fetch('http://localhost:3000/create-user', { + method: 'POST', + body: JSON.stringify(testUserPayload), + headers: { 'Content-Type': 'application/json' } + }) - // #3 Keep credentials of test user - testUser = await testUserData.json() - }) + // #3 Keep credentials of test user + testUser = await testUserData.json() + }) - // #4 Login with test user credentials before each test - playwright.beforeEach(async ({ page }) => { - await page.goto('http://localhost:3000/sign-in') - await page.getByTestId('sign-in-email').fill(testUser.email) - await page.getByTestId('sign-in-password').fill(testUser.password) - await page.getByTestId('sign-in-submit').click() + // #4 Login with test user credentials before each test + playwright.beforeEach(async ({ page }) => { + await page.goto('http://localhost:3000/sign-in') + await page.getByTestId('sign-in-email').fill(testUser.email) + await page.getByTestId('sign-in-password').fill(testUser.password) + await page.getByTestId('sign-in-submit').click() + }) }) }) diff --git a/lib/annotation.decorator.ts b/lib/annotation.decorator.ts index 37f5e93..dcde9d2 100644 --- a/lib/annotation.decorator.ts +++ b/lib/annotation.decorator.ts @@ -1,6 +1,4 @@ -import { isTestDecoratedMethod } from './test.decorator' -import { NotTestDecoratedMethodError } from './errors' -import { TestMethod } from './common' +import { createTestDecorator } from './custom' interface AnnotationDecoratorOptions { type: 'skip' | 'fail' | 'issue' | 'slow' | string @@ -12,14 +10,6 @@ interface AnnotationDecoratorOptions { * Annotations are accessible via test.info().annotations. Many reporters show annotations, for example 'html'. */ export const annotation = (options: AnnotationDecoratorOptions) => - function ( - originalMethod: TestMethod, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - context: ClassMethodDecoratorContext - ) { - if (isTestDecoratedMethod(originalMethod)) { - originalMethod.testDecorator.annotations.push(options) - } else { - throw new NotTestDecoratedMethodError('annotation', originalMethod) - } - } + createTestDecorator('annotation', ({ test }) => { + test.annotations.push(options) + }) diff --git a/lib/common.ts b/lib/common.ts index 1387546..28c29f9 100644 --- a/lib/common.ts +++ b/lib/common.ts @@ -1,12 +1,12 @@ import { PlaywrightTestArgs, - TestInfo, PlaywrightTestOptions, PlaywrightWorkerArgs, - PlaywrightWorkerOptions + PlaywrightWorkerOptions, + TestInfo as PlaywrightTestInfo } from '@playwright/test' -export { TestInfo } from '@playwright/test' +export type TestInfo = PlaywrightTestInfo export type TestArgs = PlaywrightTestArgs & PlaywrightTestOptions & PlaywrightWorkerArgs & diff --git a/lib/custom.ts b/lib/custom.ts index e4aae64..46f2a61 100644 --- a/lib/custom.ts +++ b/lib/custom.ts @@ -1,10 +1,56 @@ import { isSuiteDecoratedMethod, SuiteDecorator } from './suite.decorator' import { isTestDecoratedMethod, TestDecorator } from './test.decorator' -import { NotSuiteDecoratedMethodError, NotTestDecoratedMethodError } from './errors' import { TestClass, TestMethod } from './common' +export class NotSuiteDecoratedMethodError extends Error { + constructor(decoratorName: string, method: TestClass) { + super(` +The @${decoratorName} decorator can only be used on class that also have the @suite decorator. +Make sure ${method?.name} is marked with @suite, and that ${decoratorName} comes before @suite, like this: + +@${decoratorName} +@suite() +${method?.name}() {}`) + } +} + +export class NotTestDecoratedMethodError extends Error { + constructor(decoratorName: string, method: TestMethod) { + super(` +The @${decoratorName} decorator can only be used on methods that also have the @test decorator. +Make sure ${method?.name} is marked with @test, and that ${decoratorName} comes before @test, like this: + +@${decoratorName} +@test() +${method?.name}() {}`) + } +} + +export class NotSuiteOrTestDecoratedMethodError extends Error { + constructor(decoratorName: string, method: TestClass | TestMethod) { + super(` +The @${decoratorName} decorator can only be used on classes/methods that also have the @suite or @test decorator. +Make sure ${method?.name} is marked with @suite or @test, and that ${decoratorName} comes before @suite or @test, like this: + +@${decoratorName} +@suite() / @test() +${method?.name}() {} + `) + } +} + type CustomSuiteDecorator = (params: { + /** + * @suite decorator context + */ suite: SuiteDecorator + /** + * The suite class that is being decorated. + */ + suiteClass: TestClass + /** + * The context of the suite class that is being decorated. + */ context: ClassDecoratorContext }) => void @@ -15,22 +61,31 @@ type CustomSuiteDecorator = (params: { * @param suiteDecorator a custom decorator function */ export const createSuiteDecorator = (name: string, suiteDecorator: CustomSuiteDecorator) => { - return function (originalMethod: TestClass, context: ClassDecoratorContext) { - if (!isSuiteDecoratedMethod(originalMethod)) { - throw new NotSuiteDecoratedMethodError(name, originalMethod) + return function (suiteClass: TestClass, context: ClassDecoratorContext) { + if (!isSuiteDecoratedMethod(suiteClass)) { + throw new NotSuiteDecoratedMethodError(name, suiteClass) } - originalMethod.suiteDecorator.initialized(() => { - suiteDecorator({ - suite: originalMethod.suiteDecorator, - context - }) + suiteDecorator({ + suite: suiteClass.suiteDecorator, + suiteClass: suiteClass, + context }) } } type CustomTestDecorator = (params: { + /** + * @test decorator context + */ test: TestDecorator + /** + * The test method that is being decorated. + */ + testMethod: TestMethod + /** + * The context of the test method that is being decorated. + */ context: ClassMethodDecoratorContext }) => void @@ -41,14 +96,52 @@ type CustomTestDecorator = (params: { * @param testDecorator a custom decorator function */ export const createTestDecorator = (name: string, testDecorator: CustomTestDecorator) => { - return function (originalMethod: TestMethod, context: ClassMethodDecoratorContext) { - if (!isTestDecoratedMethod(originalMethod)) { - throw new NotTestDecoratedMethodError(name, originalMethod) + return function (testMethod: TestMethod, context: ClassMethodDecoratorContext) { + if (!isTestDecoratedMethod(testMethod)) { + throw new NotTestDecoratedMethodError(name, testMethod) } testDecorator({ - test: originalMethod.testDecorator, + test: testMethod.testDecorator, + testMethod, context }) } } + +/** + * Generates a decorator specifically intended for use with both @suite and @test. + * @param name name of the decorator + * @param suiteDecorator a custom decorator function intended for use with @suite + * @param testDecorator a custom decorator function intended for use with @test + */ +export const createSuiteAndTestDecorator = ( + name: string, + suiteDecorator: CustomSuiteDecorator, + testDecorator: CustomTestDecorator +) => { + return function ( + originalMethod: TestClass | TestMethod, + context: ClassDecoratorContext | ClassMethodDecoratorContext + ) { + if (isSuiteDecoratedMethod(originalMethod)) { + suiteDecorator({ + suite: originalMethod.suiteDecorator, + suiteClass: originalMethod as TestClass, + context: context as ClassDecoratorContext + }) + return + } + + if (isTestDecoratedMethod(originalMethod)) { + testDecorator({ + test: originalMethod.testDecorator, + testMethod: originalMethod as TestMethod, + context: context as ClassMethodDecoratorContext + }) + return + } + + throw new NotSuiteOrTestDecoratedMethodError(name, originalMethod) + } +} diff --git a/lib/errors.ts b/lib/errors.ts deleted file mode 100644 index 8dd6a9b..0000000 --- a/lib/errors.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { TestClass, TestMethod } from './common' - -export class NotSuiteDecoratedMethodError extends Error { - constructor(decoratorName: string, method: TestClass) { - super(` -The @${decoratorName} decorator can only be used on class that also have the @suite decorator. -Make sure ${method?.name} is marked with @suite, and that ${decoratorName} comes before @suite, like this: - -@${decoratorName} -@suite() -${method?.name}() {}`) - } -} - -export class NotTestDecoratedMethodError extends Error { - constructor(decoratorName: string, method: TestMethod) { - super(` -The @${decoratorName} decorator can only be used on methods that also have the @test decorator. -Make sure ${method?.name} is marked with @test, and that ${decoratorName} comes before @test, like this: - -@${decoratorName} -@test() -${method?.name}() {}`) - } -} - -export class NotSuiteOrTestDecoratedMethodError extends Error { - constructor(decoratorName: string, method: TestClass | TestMethod) { - super(` -The @${decoratorName} decorator can only be used on classes/methods that also have the @suite or @test decorator. -Make sure ${method?.name} is marked with @suite or @test, and that ${decoratorName} comes before @suite or @test, like this: - -@${decoratorName} -@suite() / @test() -${method?.name}() {} - `) - } -} diff --git a/lib/fail.decorator.ts b/lib/fail.decorator.ts index 8b045a7..1c3cd45 100644 --- a/lib/fail.decorator.ts +++ b/lib/fail.decorator.ts @@ -1,7 +1,4 @@ -import { isSuiteDecoratedMethod } from './suite.decorator' -import { isTestDecoratedMethod } from './test.decorator' -import { NotSuiteOrTestDecoratedMethodError } from './errors' -import { TestClass, TestMethod } from './common' +import { createSuiteAndTestDecorator } from './custom' /** * Marks a @test or @suite as "should fail". @@ -9,20 +6,12 @@ import { TestClass, TestMethod } from './common' * This is useful for documentation purposes to acknowledge that some functionality is broken until it is fixed. */ export const fail = (reason?: string) => - function ( - originalMethod: TestClass | TestMethod, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - context: ClassDecoratorContext | ClassMethodDecoratorContext - ) { - if (isSuiteDecoratedMethod(originalMethod)) { - originalMethod.suiteDecorator.fail = reason || true - return + createSuiteAndTestDecorator( + 'fail', + ({ suite }) => { + suite.fail = reason || true + }, + ({ test }) => { + test.fail = reason || true } - - if (isTestDecoratedMethod(originalMethod)) { - originalMethod.testDecorator.fail = reason || true - return - } - - throw new NotSuiteOrTestDecoratedMethodError('fail', originalMethod) - } + ) diff --git a/lib/fixme.decorator.ts b/lib/fixme.decorator.ts index 0341446..4c478ce 100644 --- a/lib/fixme.decorator.ts +++ b/lib/fixme.decorator.ts @@ -1,27 +1,16 @@ -import { isSuiteDecoratedMethod } from './suite.decorator' -import { isTestDecoratedMethod } from './test.decorator' -import { NotSuiteOrTestDecoratedMethodError } from './errors' -import { TestClass, TestMethod } from './common' +import { createSuiteAndTestDecorator } from './custom' /** * Marks a @test or @suite as "fixme", with the intention to fix (with optional reason). * Decorated tests or suites will not be run. */ export const fixme = (reason?: string) => - function ( - originalMethod: TestClass | TestMethod, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - context: ClassDecoratorContext | ClassMethodDecoratorContext - ) { - if (isSuiteDecoratedMethod(originalMethod)) { - originalMethod.suiteDecorator.fixme = reason || true - return + createSuiteAndTestDecorator( + 'fixme', + ({ suite }) => { + suite.fixme = reason || true + }, + ({ test }) => { + test.fixme = reason || true } - - if (isTestDecoratedMethod(originalMethod)) { - originalMethod.testDecorator.fixme = reason || true - return - } - - throw new NotSuiteOrTestDecoratedMethodError('fixme', originalMethod) - } + ) diff --git a/lib/index.ts b/lib/index.ts index fc76031..498f697 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -23,15 +23,8 @@ export { annotation } from './annotation.decorator' // helpers export { tag } from './tag.decorator' -// errors -export { - NotSuiteOrTestDecoratedMethodError, - NotSuiteDecoratedMethodError, - NotTestDecoratedMethodError -} from './errors' - // common -export type { TestInfo, TestArgs } from './common' +export { type TestInfo, type TestArgs } from './common' // custom -export { createSuiteDecorator, createTestDecorator } from './custom' +export { createSuiteDecorator, createTestDecorator, createSuiteAndTestDecorator } from './custom' diff --git a/lib/only.decorator.ts b/lib/only.decorator.ts index 525a4a7..ec78c0f 100644 --- a/lib/only.decorator.ts +++ b/lib/only.decorator.ts @@ -1,27 +1,16 @@ -import { isSuiteDecoratedMethod } from './suite.decorator' -import { isTestDecoratedMethod } from './test.decorator' -import { NotSuiteOrTestDecoratedMethodError } from './errors' -import { TestClass, TestMethod } from './common' +import { createSuiteAndTestDecorator } from './custom' /** * Declares a focused test. * If there are some focused @test(s) or @suite(s), all of them will be run but nothing else. */ export const only = () => - function ( - originalMethod: TestClass | TestMethod, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - context: ClassDecoratorContext | ClassMethodDecoratorContext - ) { - if (isSuiteDecoratedMethod(originalMethod)) { - originalMethod.suiteDecorator.only = true - return + createSuiteAndTestDecorator( + 'only', + ({ suite }) => { + suite.only = true + }, + ({ test }) => { + test.only = true } - - if (isTestDecoratedMethod(originalMethod)) { - originalMethod.testDecorator.only = true - return - } - - throw new NotSuiteOrTestDecoratedMethodError('only', originalMethod) - } + ) diff --git a/lib/skip.decorator.ts b/lib/skip.decorator.ts index 2d06664..7843ed2 100644 --- a/lib/skip.decorator.ts +++ b/lib/skip.decorator.ts @@ -1,26 +1,15 @@ -import { isSuiteDecoratedMethod } from './suite.decorator' -import { isTestDecoratedMethod } from './test.decorator' -import { NotSuiteOrTestDecoratedMethodError } from './errors' -import { TestClass, TestMethod } from './common' +import { createSuiteAndTestDecorator } from './custom' /** * Skip @test or @suite (with optional reason). */ export const skip = (reason?: string) => - function ( - originalMethod: TestClass | TestMethod, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - context: ClassDecoratorContext | ClassMethodDecoratorContext - ) { - if (isSuiteDecoratedMethod(originalMethod)) { - originalMethod.suiteDecorator.skip = reason || true - return + createSuiteAndTestDecorator( + 'skip', + ({ suite }) => { + suite.skip = reason || true + }, + ({ test }) => { + test.skip = reason || true } - - if (isTestDecoratedMethod(originalMethod)) { - originalMethod.testDecorator.skip = reason || true - return - } - - throw new NotSuiteOrTestDecoratedMethodError('skip', originalMethod) - } + ) diff --git a/lib/slow.decorator.ts b/lib/slow.decorator.ts index e29ea8e..0e93764 100644 --- a/lib/slow.decorator.ts +++ b/lib/slow.decorator.ts @@ -1,27 +1,16 @@ -import { isSuiteDecoratedMethod } from './suite.decorator' -import { isTestDecoratedMethod } from './test.decorator' -import { NotSuiteOrTestDecoratedMethodError } from './errors' -import { TestClass, TestMethod } from './common' +import { createSuiteAndTestDecorator } from './custom' /** * Marks a @test or @suite as "slow" (with optional reason). * Slow test will be given triple the default timeout. */ export const slow = (reason?: string) => - function ( - originalMethod: TestClass | TestMethod, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - context: ClassDecoratorContext | ClassMethodDecoratorContext - ) { - if (isSuiteDecoratedMethod(originalMethod)) { - originalMethod.suiteDecorator.slow = reason || true - return + createSuiteAndTestDecorator( + 'slow', + ({ suite }) => { + suite.slow = reason || true + }, + ({ test }) => { + test.slow = reason || true } - - if (isTestDecoratedMethod(originalMethod)) { - originalMethod.testDecorator.slow = reason || true - return - } - - throw new NotSuiteOrTestDecoratedMethodError('slow', originalMethod) - } + ) diff --git a/lib/tag.decorator.ts b/lib/tag.decorator.ts index ae4ceb2..b98f118 100644 --- a/lib/tag.decorator.ts +++ b/lib/tag.decorator.ts @@ -1,30 +1,19 @@ -import { isSuiteDecoratedMethod } from './suite.decorator' -import { isTestDecoratedMethod } from './test.decorator' -import { NotSuiteOrTestDecoratedMethodError } from './errors' -import { TestClass, TestMethod } from './common' +import { createSuiteAndTestDecorator } from './custom' +const tagsAsPlaywrightAnnotations = (tags: string[]): string => + tags.map((tag) => `@${tag}`).join(' ') /** * Adds tags to `@test` or `@suite`. * You can later run test(s) or suite(s) with specific tag, using `npx playwright test --grep "@nameOfTag"` command. * For example: to run tests/suites with `x` tag, please run `npx playwright test --grep "@x"` */ export const tag = (tags: string[]) => - function ( - originalMethod: TestClass | TestMethod, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - context: ClassDecoratorContext | ClassMethodDecoratorContext - ) { - const tagsAsPlaywrightAnnotations = tags.map((tag) => `@${tag}`).join(' ') - - if (isSuiteDecoratedMethod(originalMethod)) { - originalMethod.suiteDecorator.name = `${originalMethod.suiteDecorator.name} ${tagsAsPlaywrightAnnotations}` - return - } - - if (isTestDecoratedMethod(originalMethod)) { - originalMethod.testDecorator.name = `${originalMethod.testDecorator.name} ${tagsAsPlaywrightAnnotations}` - return + createSuiteAndTestDecorator( + 'tag', + ({ suite }) => { + suite.name = `${suite.name} ${tagsAsPlaywrightAnnotations(tags)}` + }, + ({ test }) => { + test.name = `${test.name} ${tagsAsPlaywrightAnnotations(tags)}` } - - throw new NotSuiteOrTestDecoratedMethodError('tag', originalMethod) - } + ) diff --git a/tests/annotation.spec.ts b/tests/annotation.spec.ts index 4d182db..60c94b4 100644 --- a/tests/annotation.spec.ts +++ b/tests/annotation.spec.ts @@ -1,6 +1,6 @@ import playwright, { expect } from '@playwright/test' import { suite, test, annotation } from '../lib' -import { NotTestDecoratedMethodError } from '../lib/errors' +import { NotTestDecoratedMethodError } from '../lib/custom' playwright.describe('@annotate decorator', () => { playwright.describe('with @test', () => { diff --git a/tests/custom.spec.ts b/tests/custom.spec.ts index 1775090..c98289a 100644 --- a/tests/custom.spec.ts +++ b/tests/custom.spec.ts @@ -1,12 +1,6 @@ import playwright, { expect } from '@playwright/test' -import { - suite, - test, - createSuiteDecorator, - createTestDecorator, - NotTestDecoratedMethodError, - NotSuiteDecoratedMethodError -} from '../lib' +import { suite, test, createSuiteDecorator, createTestDecorator } from '../lib' +import { NotSuiteDecoratedMethodError, NotTestDecoratedMethodError } from '../lib/custom' playwright.describe('custom decorators', () => { playwright.describe('createSuiteDecorator', () => { diff --git a/tests/fail.spec.ts b/tests/fail.spec.ts index c9ad26e..393eaef 100644 --- a/tests/fail.spec.ts +++ b/tests/fail.spec.ts @@ -1,5 +1,6 @@ import playwright, { expect } from '@playwright/test' -import { suite, test, fail, NotSuiteOrTestDecoratedMethodError } from '../lib' +import { suite, test, fail } from '../lib' +import { NotSuiteOrTestDecoratedMethodError } from '../lib/custom' playwright.describe('@fail decorator', () => { playwright.describe('with @suite', () => { diff --git a/tests/fixme.spec.ts b/tests/fixme.spec.ts index 6254a02..f67f1d1 100644 --- a/tests/fixme.spec.ts +++ b/tests/fixme.spec.ts @@ -1,5 +1,6 @@ import playwright, { expect } from '@playwright/test' -import { suite, test, fixme, NotSuiteOrTestDecoratedMethodError } from '../lib' +import { suite, test, fixme } from '../lib' +import { NotSuiteOrTestDecoratedMethodError } from '../lib/custom' playwright.describe('@fixme decorator', () => { playwright.describe('with @suite', () => { diff --git a/tests/only.spec.ts b/tests/only.spec.ts index 91d40a8..0b6c8fd 100644 --- a/tests/only.spec.ts +++ b/tests/only.spec.ts @@ -1,5 +1,6 @@ import playwright, { expect } from '@playwright/test' -import { suite, test, only, NotSuiteOrTestDecoratedMethodError } from '../lib' +import { suite, test, only } from '../lib' +import { NotSuiteOrTestDecoratedMethodError } from '../lib/custom' import { mockFn } from './__mocks__/mockFn' playwright.describe('@only decorator', () => { diff --git a/tests/skip.spec.ts b/tests/skip.spec.ts index c13c9b9..7ab82e6 100644 --- a/tests/skip.spec.ts +++ b/tests/skip.spec.ts @@ -1,5 +1,6 @@ import playwright, { expect } from '@playwright/test' -import { suite, test, slow, beforeAll, skip, NotSuiteOrTestDecoratedMethodError } from '../lib' +import { suite, test, skip } from '../lib' +import { NotSuiteOrTestDecoratedMethodError } from '../lib/custom' playwright.describe('@skip decorator', () => { playwright.describe('with @suite', () => { diff --git a/tests/slow.spec.ts b/tests/slow.spec.ts index 7086230..692bef0 100644 --- a/tests/slow.spec.ts +++ b/tests/slow.spec.ts @@ -1,5 +1,6 @@ import playwright, { expect } from '@playwright/test' -import { suite, test, slow, beforeAll, only, NotSuiteOrTestDecoratedMethodError } from '../lib' +import { suite, test, slow } from '../lib' +import { NotSuiteOrTestDecoratedMethodError } from '../lib/custom' import { mockFn } from './__mocks__/mockFn' playwright.describe('@slow decorator', () => { diff --git a/tests/tag.spec.ts b/tests/tag.spec.ts index b2ff21c..99c626a 100644 --- a/tests/tag.spec.ts +++ b/tests/tag.spec.ts @@ -1,5 +1,6 @@ -import playwright, { expect, TestInfo } from '@playwright/test' -import { NotSuiteOrTestDecoratedMethodError, suite, tag, test, TestArgs } from '../lib' +import playwright, { expect } from '@playwright/test' +import { suite, tag, test, TestArgs, TestInfo } from '../lib' +import { NotSuiteOrTestDecoratedMethodError } from '../lib/custom' playwright.describe('@tag decorator', () => { playwright.describe('with @suite', () => {