diff --git a/lib/afterAll.decorator.ts b/lib/afterAll.decorator.ts index f885553..6f06589 100644 --- a/lib/afterAll.decorator.ts +++ b/lib/afterAll.decorator.ts @@ -14,7 +14,7 @@ export interface AfterAllDecoratorOptions { * Run method after all tests in the suite. * Target class should be marked by @suite decorator. */ -export const afterAll = (options?: AfterAllDecoratorOptions) => +export const afterAll = (options?: AfterAllDecoratorOptions) => function (originalMethod: TestMethod, context: ClassMethodDecoratorContext) { context.addInitializer(function () { const decoratedBeforeAll = decoratePlaywrightTest( diff --git a/lib/afterEach.decorator.ts b/lib/afterEach.decorator.ts index b25cc39..7bbb8d8 100644 --- a/lib/afterEach.decorator.ts +++ b/lib/afterEach.decorator.ts @@ -14,7 +14,7 @@ export interface AfterEachDecoratorOptions { * Run method after each test in suite. * Target class should be marked by @suite decorator. */ -export const afterEach = (options?: AfterEachDecoratorOptions) => +export const afterEach = (options?: AfterEachDecoratorOptions) => function (originalMethod: TestMethod, context: ClassMethodDecoratorContext) { context.addInitializer(function () { const decoratedBeforeEach = decoratePlaywrightTest( diff --git a/lib/beforeAll.decorator.ts b/lib/beforeAll.decorator.ts index d2a3a58..aaafad1 100644 --- a/lib/beforeAll.decorator.ts +++ b/lib/beforeAll.decorator.ts @@ -14,7 +14,7 @@ export interface BeforeAllDecoratorOptions { * Run method before all tests in the suite. * Target class should be marked by @suite decorator. */ -export const beforeAll = (options?: BeforeAllDecoratorOptions) => +export const beforeAll = (options?: BeforeAllDecoratorOptions) => function (originalMethod: TestMethod, context: ClassMethodDecoratorContext) { context.addInitializer(function () { const decoratedBeforeAll = decoratePlaywrightTest( diff --git a/lib/beforeEach.decorator.ts b/lib/beforeEach.decorator.ts index dba0b4a..5dd59e1 100644 --- a/lib/beforeEach.decorator.ts +++ b/lib/beforeEach.decorator.ts @@ -14,7 +14,7 @@ export interface BeforeEachDecoratorOptions { * Run method before each test in the suite. * Target class should be marked by @suite decorator. */ -export const beforeEach = (options?: BeforeEachDecoratorOptions) => +export const beforeEach = (options?: BeforeEachDecoratorOptions) => function (originalMethod: TestMethod, context: ClassMethodDecoratorContext) { context.addInitializer(function () { const decoratedBeforeEach = decoratePlaywrightTest( diff --git a/lib/common.ts b/lib/common.ts index 601ae54..b64b3c9 100644 --- a/lib/common.ts +++ b/lib/common.ts @@ -8,15 +8,15 @@ import { } from '@playwright/test' export type TestInfo = PlaywrightTestInfo -export type TestArgs = T & +export type TestArgs = T & PlaywrightTestArgs & PlaywrightTestOptions & PlaywrightWorkerArgs & PlaywrightWorkerOptions -export type TestMethod = (args: TestArgs, testInfo: TestInfo) => void | Promise +export type TestMethod = (args: TestArgs, testInfo: TestInfo) => void | Promise // eslint-disable-next-line @typescript-eslint/no-explicit-any export type TestClass = { new (...args: any[]): any } export type TestType = PlaywrightTestType< - TestArgs & T, + TestArgs, PlaywrightWorkerArgs & PlaywrightWorkerOptions > diff --git a/lib/test.decorator.ts b/lib/test.decorator.ts index cde4c21..88d3d09 100644 --- a/lib/test.decorator.ts +++ b/lib/test.decorator.ts @@ -96,9 +96,7 @@ export function isTestDecoratedMethod(method: any): method is TestDecoratedMetho * * Behaviour of decorator can be modified by other decorators using injected `testDecorator` property. */ -export const test = ( - options: TestDecoratorOptions = {} // @todo inject playwright -) => +export const test = (options: TestDecoratorOptions = {}) => function (originalMethod: TestMethod, context: ClassMethodDecoratorContext) { const testDecorator = new TestDecorator(originalMethod, options)