mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-13 07:35:33 +03:00
fix playwright being imported before toImpl could be registered (#3632)
This commit is contained in:
parent
a6b9922eb8
commit
f9eeb2984a
@ -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) {
|
||||
|
4
test-runner/test/assets/global-foo.js
Normal file
4
test-runner/test/assets/global-foo.js
Normal file
@ -0,0 +1,4 @@
|
||||
global.foo = true;
|
||||
module.exports = {
|
||||
abc: 123
|
||||
};
|
11
test-runner/test/assets/typescript.ts
Normal file
11
test-runner/test/assets/typescript.ts
Normal file
@ -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);
|
||||
});
|
@ -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 => {});
|
||||
|
@ -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);
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
Loading…
Reference in New Issue
Block a user