Skip to content

Commit

Permalink
chore: improve typings
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianSedzik committed Jan 24, 2024
1 parent 8451727 commit 8fa9ea3
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/afterAll.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface AfterAllDecoratorOptions<T> {
* Run method after all tests in the suite.
* Target class should be marked by @suite decorator.
*/
export const afterAll = <T = unknown>(options?: AfterAllDecoratorOptions<T>) =>
export const afterAll = <T = void>(options?: AfterAllDecoratorOptions<T>) =>
function (originalMethod: TestMethod<T>, context: ClassMethodDecoratorContext) {
context.addInitializer(function () {
const decoratedBeforeAll = decoratePlaywrightTest<T>(
Expand Down
2 changes: 1 addition & 1 deletion lib/afterEach.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface AfterEachDecoratorOptions<T> {
* Run method after each test in suite.
* Target class should be marked by @suite decorator.
*/
export const afterEach = <T = unknown>(options?: AfterEachDecoratorOptions<T>) =>
export const afterEach = <T = void>(options?: AfterEachDecoratorOptions<T>) =>
function (originalMethod: TestMethod<T>, context: ClassMethodDecoratorContext) {
context.addInitializer(function () {
const decoratedBeforeEach = decoratePlaywrightTest<T>(
Expand Down
2 changes: 1 addition & 1 deletion lib/beforeAll.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface BeforeAllDecoratorOptions<T> {
* Run method before all tests in the suite.
* Target class should be marked by @suite decorator.
*/
export const beforeAll = <T = unknown>(options?: BeforeAllDecoratorOptions<T>) =>
export const beforeAll = <T = void>(options?: BeforeAllDecoratorOptions<T>) =>
function (originalMethod: TestMethod<T>, context: ClassMethodDecoratorContext) {
context.addInitializer(function () {
const decoratedBeforeAll = decoratePlaywrightTest<T>(
Expand Down
2 changes: 1 addition & 1 deletion lib/beforeEach.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface BeforeEachDecoratorOptions<T> {
* Run method before each test in the suite.
* Target class should be marked by @suite decorator.
*/
export const beforeEach = <T = unknown>(options?: BeforeEachDecoratorOptions<T>) =>
export const beforeEach = <T = void>(options?: BeforeEachDecoratorOptions<T>) =>
function (originalMethod: TestMethod<T>, context: ClassMethodDecoratorContext) {
context.addInitializer(function () {
const decoratedBeforeEach = decoratePlaywrightTest<T>(
Expand Down
6 changes: 3 additions & 3 deletions lib/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import {
} from '@playwright/test'

export type TestInfo = PlaywrightTestInfo
export type TestArgs<T = unknown> = T &
export type TestArgs<T = void> = T &
PlaywrightTestArgs &
PlaywrightTestOptions &
PlaywrightWorkerArgs &
PlaywrightWorkerOptions
export type TestMethod<T = any> = (args: TestArgs<T>, testInfo: TestInfo) => void | Promise<void>
export type TestMethod<T = void> = (args: TestArgs<T>, testInfo: TestInfo) => void | Promise<void>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type TestClass = { new (...args: any[]): any }
export type TestType<T = any> = PlaywrightTestType<

Check warning on line 19 in lib/common.ts

View workflow job for this annotation

GitHub Actions / Code formatting

Unexpected any. Specify a different type
TestArgs & T,
TestArgs<T>,
PlaywrightWorkerArgs & PlaywrightWorkerOptions
>
4 changes: 1 addition & 3 deletions lib/test.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <T = unknown>(
options: TestDecoratorOptions = {} // @todo inject playwright
) =>
export const test = <T = void>(options: TestDecoratorOptions = {}) =>
function (originalMethod: TestMethod<T>, context: ClassMethodDecoratorContext) {
const testDecorator = new TestDecorator(originalMethod, options)

Expand Down

0 comments on commit 8fa9ea3

Please sign in to comment.