Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix playwright being imported before toImpl could be registered (#3632)
Joel Einbinderf9eeb2984a16
diff --git a/test-runner/src/transform.ts b/test-runner/src/transform.tsindex d0304592ee..a1898b1e56 100644--- a/test-runner/src/transform.ts+++ b/test-runner/src/transform.ts@@ -22,7 +22,7 @@ import * as pirates from 'pirates';import * as babel from '@babel/core';import * as sourceMapSupport from 'source-map-support';-const version = 1;+const version = 2;const cacheDir = path.join(os.tmpdir(), 'playwright-transform-cache');const sourceMaps: Map<string, string> = new Map();@@ -59,8 +59,9 @@ export function installTransform(): () => void {const result = babel.transformFileSync(filename, {presets: [- ['@babel/preset-env', {targets: {node: 'current'}}],- '@babel/preset-typescript'],+ ['@babel/preset-env', { targets: {node: 'current'} }],+ ['@babel/preset-typescript', { onlyRemoveTypeImports: true }],+ ],sourceMaps: true,});if (result.code) {diff --git a/test-runner/test/assets/global-foo.js b/test-runner/test/assets/global-foo.jsnew file mode 100644index 0000000000..ccfbc9e378--- /dev/null+++ b/test-runner/test/assets/global-foo.js@@ -0,0 +1,4 @@+global.foo = true;+module.exports = {+ abc: 123+};\ No newline at end of filediff --git a/test-runner/test/assets/typescript.ts b/test-runner/test/assets/typescript.tsnew file mode 100644index 0000000000..b8362f12d3--- /dev/null+++ b/test-runner/test/assets/typescript.ts@@ -0,0 +1,11 @@+import '../../';+import { abc } from "./global-foo";++it('should find global foo', () => {+ expect(global['foo']).toBe(true);+});++it('should work with type annotations', () => {+ const x: number = 5;+ expect(x).toBe(5);+});\ No newline at end of filediff --git a/test-runner/test/exit-code.spec.ts b/test-runner/test/exit-code.spec.tsindex 5f99f96413..b0cadde507 100644--- a/test-runner/test/exit-code.spec.ts+++ b/test-runner/test/exit-code.spec.ts@@ -76,6 +76,11 @@ it('should collect stdio', async() => {expect(stderr).toEqual([{ text: 'stderr text' }, { buffer: Buffer.from('stderr buffer').toString('base64') }]);});+it('should work with typescript', async() => {+ const result = await runTest('typescript.ts');+ expect(result.exitCode).toBe(0);+});+async function runTest(filePath: string, timeout = 10000) {const outputDir = path.join(__dirname, 'test-results')await removeFolderAsync(outputDir).catch(e => {});diff --git a/test/chromium/session.spec.ts b/test/chromium/session.spec.tsindex 156dd3ca9d..55b2347ff0 100644--- a/test/chromium/session.spec.ts+++ b/test/chromium/session.spec.ts@@ -14,7 +14,7 @@* limitations under the License.*/import { options } from '../playwright.fixtures';-import { ChromiumBrowserContext, ChromiumBrowser } from "../../types/types";+import type { ChromiumBrowserContext, ChromiumBrowser } from "../../types/types";it.skip(!options.CHROMIUM)('should work', async function({page}) {const client = await (page.context() as ChromiumBrowserContext).newCDPSession(page);diff --git a/test/electron/electron.fixture.ts b/test/electron/electron.fixture.tsindex 3d35a2e7f7..59c40f42c0 100644--- a/test/electron/electron.fixture.ts+++ b/test/electron/electron.fixture.ts@@ -16,7 +16,7 @@import { options } from '../playwright.fixtures';import { registerFixture } from '../../test-runner';-import {ElectronApplication, ElectronLauncher, ElectronPage} from '../../electron-types';+import type {ElectronApplication, ElectronLauncher, ElectronPage} from '../../electron-types';import path from 'path';const electronName = process.platform === 'win32' ? 'electron.cmd' : 'electron';diff --git a/test/playwright.fixtures.ts b/test/playwright.fixtures.tsindex 3b58e454cc..979be85c19 100644--- a/test/playwright.fixtures.ts+++ b/test/playwright.fixtures.ts@@ -18,7 +18,7 @@ import fs from 'fs';import path from 'path';import os from 'os';import childProcess from 'child_process';-import { LaunchOptions, BrowserType, Browser, BrowserContext, Page, BrowserServer } from '../index';+import type { LaunchOptions, BrowserType, Browser, BrowserContext, Page, BrowserServer } from '../index';import { TestServer } from '../utils/testserver';import { Connection } from '../lib/client/connection';import { Transport } from '../lib/protocol/transport';