From 4f43db686df314a6221d819f48950c1f379f3f19 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 20 Mar 2023 16:38:51 +0100 Subject: [PATCH] test: class properties with |this| don't work anymore (#21796) https://github.com/microsoft/playwright/issues/21794 --- tests/playwright-test/babel.spec.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/playwright-test/babel.spec.ts b/tests/playwright-test/babel.spec.ts index 20877ac2f2..2f443f9bbd 100644 --- a/tests/playwright-test/babel.spec.ts +++ b/tests/playwright-test/babel.spec.ts @@ -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); +});