-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed as not planned
Closed as not planned
Copy link
Description
System info
Playwright Version: [^1.32.1]
Operating System: [Windows11]
Browser: [Chromium]
During the implementing playwright step decorators into our existing tests infrastructure we faced issue with decorators.
i followed the implementation as described in below https://playwright.dev/docs/api/class-test#test-step
i see the following error
import { Page,expect,test } from "@playwright/test";
function step(target: Function, context: ClassMethodDecoratorContext) {
return function replacementMethod(...args: any) {
const name = this.constructor.name + '.' + (context.name as string);
return test.step(name, async () => {
return await target.call(this, ...args);
});
};
}
class LoginPage {
constructor(readonly page: Page) {}
@step
async login() {
const account = { username: 'Alice', password: 's3cr3t' };
await this.page.getByLabel('Username or email address').fill(account.username);
await this.page.getByLabel('Password').fill(account.password);
await this.page.getByRole('button', { name: 'Sign in' }).click();
await expect(this.page.getByRole('button', { name: 'View profile and more' })).toBeVisible();
}
}
test('example', async ({ page }) => {
const loginPage = new LoginPage(page);
await loginPage.login();
});tsconfig.json
{
"compilerOptions": {
"target": "ES6",
"esModuleInterop": true,
"module": "commonjs",
"moduleResolution": "node",
"lib": ["es2019", "DOM", "ES6", "DOM.Iterable", "ScriptHost"],
"sourceMap": true,
"declaration": true,
"removeComments": false,
"noImplicitAny": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"types": ["jasmine", "node"],
"allowJs": false,
"rootDir": "./",
"outDir": "build-js",
"baseUrl": ".",
"paths": {
"#root": ["."]
}
},
"include": ["src/**/*"],
"exclude": ["node_modules", "build-js"]
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
