test: class properties with |this| don't work anymore (#21796)

https://github.com/microsoft/playwright/issues/21794
This commit is contained in:
Max Schmitt 2023-03-20 16:38:51 +01:00 committed by GitHub
parent d641caeb6a
commit 4f43db686d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -75,3 +75,23 @@ test('should treat enums equally', async ({ runInlineTest }) => {
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(1);
});
test('should be able to access |this| inside class properties', async ({ runInlineTest }) => {
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/21794' });
const result = await runInlineTest({
'example.spec.ts': `
import { test, expect } from '@playwright/test';
class Foo {
constructor(private readonly incoming: number) {}
value = this.incoming;
}
test('works', () => {
expect(new Foo(42).value).toBe(42);
})
`,
});
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(1);
});