Skip to content

Commit

Permalink
fix: support even older node 12 (#9718) (#9804)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelEinbinder authored Oct 26, 2021
1 parent 7ba8ba7 commit 2b59574
Show file tree
Hide file tree
Showing 30 changed files with 52 additions and 46 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests_secondary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ jobs:
fail-fast: false
matrix:
node_version:
- "12.0.0"
- "^12.0.0"
- "^14.1.0" # pre 14.1, zip extraction was broken (https://github.com/microsoft/playwright/issues/1988)
- "^16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion install-from-github.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ try {
}

console.log(`Downloading browsers...`);
const { installDefaultBrowsersForNpmInstall } = require('playwright-core/src/utils/registry');
const { installDefaultBrowsersForNpmInstall } = require('playwright-core/lib/utils/registry');
installDefaultBrowsersForNpmInstall().catch(e => {
console.error(`Failed to install browsers, caused by\n${e.stack}`);
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-chromium/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* limitations under the License.
*/

const { installBrowsersForNpmInstall } = require('playwright-core/src/utils/registry');
const { installBrowsersForNpmInstall } = require('playwright-core/lib/utils/registry');

installBrowsersForNpmInstall(['chromium', 'ffmpeg']);
18 changes: 9 additions & 9 deletions packages/playwright-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
"require": "./index.js"
},
"./cli": "./cli.js",
"./src/grid/gridServer": "./lib/grid/gridServer.js",
"./src/grid/gridClient": "./lib/grid/gridClient.js",
"./src/grid/dockerGridFactory": "./lib/grid/dockerGridFactory.js",
"./src/utils/async": "./lib/utils/async.js",
"./src/utils/httpServer": "./lib/utils/httpServer.js",
"./src/utils/multimap": "./lib/utils/multimap.js",
"./src/utils/processLauncher": "./lib/utils/processLauncher.js",
"./src/utils/registry": "./lib/utils/registry.js",
"./src/utils/utils": "./lib/utils/utils.js"
"./lib/grid/gridServer": "./lib/grid/gridServer.js",
"./lib/grid/gridClient": "./lib/grid/gridClient.js",
"./lib/grid/dockerGridFactory": "./lib/grid/dockerGridFactory.js",
"./lib/utils/async": "./lib/utils/async.js",
"./lib/utils/httpServer": "./lib/utils/httpServer.js",
"./lib/utils/multimap": "./lib/utils/multimap.js",
"./lib/utils/processLauncher": "./lib/utils/processLauncher.js",
"./lib/utils/registry": "./lib/utils/registry.js",
"./lib/utils/utils": "./lib/utils/utils.js"
},
"types": "types/types.d.ts",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-firefox/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* limitations under the License.
*/

const { installBrowsersForNpmInstall } = require('playwright-core/src/utils/registry');
const { installBrowsersForNpmInstall } = require('playwright-core/lib/utils/registry');

installBrowsersForNpmInstall(['firefox']);
6 changes: 3 additions & 3 deletions packages/playwright-test/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import { stopProfiling, startProfiling } from './profiler';
import { FilePatternFilter } from './util';
import { Loader } from './loader';
import { showHTMLReport } from './reporters/html';
import { GridServer } from 'playwright-core/src/grid/gridServer';
import dockerFactory from 'playwright-core/src/grid/dockerGridFactory';
import { createGuid } from 'playwright-core/src/utils/utils';
import { GridServer } from 'playwright-core/lib/grid/gridServer';
import dockerFactory from 'playwright-core/lib/grid/dockerGridFactory';
import { createGuid } from 'playwright-core/lib/utils/utils';

const defaultTimeout = 30000;
const defaultReporter: BuiltInReporter = process.env.CI ? 'dot' : 'list';
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright-test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import * as path from 'path';
import type { LaunchOptions, BrowserContextOptions, Page, BrowserContext, BrowserType } from 'playwright-core';
import type { TestType, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, TestInfo } from '../types/test';
import { rootTestType } from './testType';
import { assert, createGuid, removeFolders } from 'playwright-core/src/utils/utils';
import { GridClient } from 'playwright-core/src/grid/gridClient';
import { assert, createGuid, removeFolders } from 'playwright-core/lib/utils/utils';
import { GridClient } from 'playwright-core/lib/grid/gridClient';
import { Browser } from 'playwright-core';
export { expect } from './expect';
export const _baseTest: TestType<{}, {}> = rootTestType.test;
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-test/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import * as fs from 'fs';
import { ProjectImpl } from './project';
import { Reporter } from '../types/testReporter';
import { BuiltInReporter, builtInReporters } from './runner';
import { isRegExp } from 'playwright-core/src/utils/utils';
import { isRegExp } from 'playwright-core/lib/utils/utils';

export class Loader {
private _defaultConfig: Config;
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright-test/src/matchers/matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

import { Locator, Page } from 'playwright-core';
import { FrameExpectOptions } from 'playwright-core/src/client/types';
import { constructURLBasedOnBaseURL } from 'playwright-core/src/utils/utils';
import { FrameExpectOptions } from 'playwright-core/lib/client/types';
import { constructURLBasedOnBaseURL } from 'playwright-core/lib/utils/utils';
import type { Expect } from '../types';
import { toBeTruthy } from './toBeTruthy';
import { toEqual } from './toEqual';
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright-test/src/matchers/toMatchText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@


import colors from 'colors/safe';
import { ExpectedTextValue } from 'playwright-core/src/protocol/channels';
import { isRegExp, isString } from 'playwright-core/src/utils/utils';
import { ExpectedTextValue } from 'playwright-core/lib/protocol/channels';
import { isRegExp, isString } from 'playwright-core/lib/utils/utils';
import { currentTestInfo } from '../globals';
import type { Expect } from '../types';
import { expectType } from '../util';
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright-test/src/reporters/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import fs from 'fs';
import open from 'open';
import path from 'path';
import { FullConfig, Suite } from '../../types/testReporter';
import { HttpServer } from 'playwright-core/src/utils/httpServer';
import { calculateSha1, removeFolders } from 'playwright-core/src/utils/utils';
import { HttpServer } from 'playwright-core/lib/utils/httpServer';
import { calculateSha1, removeFolders } from 'playwright-core/lib/utils/utils';
import RawReporter, { JsonReport, JsonSuite, JsonTestCase, JsonTestResult, JsonTestStep, JsonAttachment } from './raw';
import assert from 'assert';

Expand Down
4 changes: 2 additions & 2 deletions packages/playwright-test/src/reporters/raw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import fs from 'fs';
import path from 'path';
import { FullConfig, Location, Suite, TestCase, TestResult, TestStatus, TestStep } from '../../types/testReporter';
import { assert, calculateSha1 } from 'playwright-core/src/utils/utils';
import { assert, calculateSha1 } from 'playwright-core/lib/utils/utils';
import { sanitizeForFilePath } from '../util';
import { formatResultFailure } from './base';
import { toPosixPath, serializePatterns } from './json';
import { MultiMap } from 'playwright-core/src/utils/multimap';
import { MultiMap } from 'playwright-core/lib/utils/multimap';
import { codeFrameColumns } from '@babel/code-frame';

export type JsonLocation = Location;
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-test/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { ProjectImpl } from './project';
import { Minimatch } from 'minimatch';
import { FullConfig } from './types';
import { WebServer } from './webServer';
import { raceAgainstDeadline } from 'playwright-core/src/utils/async';
import { raceAgainstDeadline } from 'playwright-core/lib/utils/async';

const removeFolderAsync = promisify(rimraf);
const readDirAsync = promisify(fs.readdir);
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-test/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import url from 'url';
import type { TestError, Location } from './types';
import { default as minimatch } from 'minimatch';
import debug from 'debug';
import { isRegExp } from 'playwright-core/src/utils/utils';
import { isRegExp } from 'playwright-core/lib/utils/utils';

export function serializeError(error: Error | any): TestError {
if (error instanceof Error) {
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright-test/src/webServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import net from 'net';
import os from 'os';
import stream from 'stream';
import { monotonicTime } from './util';
import { raceAgainstDeadline } from 'playwright-core/src/utils/async';
import { raceAgainstDeadline } from 'playwright-core/lib/utils/async';
import { WebServerConfig } from './types';
import { launchProcess } from 'playwright-core/src/utils/processLauncher';
import { launchProcess } from 'playwright-core/lib/utils/processLauncher';

const DEFAULT_ENVIRONMENT_VARIABLES = {
'BROWSER': 'none', // Disable that create-react-app will open the page in the browser
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-test/src/workerRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { Modifier, Suite, TestCase } from './test';
import { Annotations, TestError, TestInfo, TestInfoImpl, TestStepInternal, WorkerInfo } from './types';
import { ProjectImpl } from './project';
import { FixturePool, FixtureRunner } from './fixtures';
import { DeadlineRunner, raceAgainstDeadline } from 'playwright-core/src/utils/async';
import { DeadlineRunner, raceAgainstDeadline } from 'playwright-core/lib/utils/async';

const removeFolderAsync = util.promisify(rimraf);

Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-webkit/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* limitations under the License.
*/

const { installBrowsersForNpmInstall } = require('playwright-core/src/utils/registry');
const { installBrowsersForNpmInstall } = require('playwright-core/lib/utils/registry');

installBrowsersForNpmInstall(['webkit']);
2 changes: 1 addition & 1 deletion packages/playwright/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* limitations under the License.
*/

const { installDefaultBrowsersForNpmInstall } = require('playwright-core/src/utils/registry');
const { installDefaultBrowsersForNpmInstall } = require('playwright-core/lib/utils/registry');

installDefaultBrowsersForNpmInstall();
2 changes: 1 addition & 1 deletion tests/browsertype-connect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { playwrightTest as test, expect } from './config/browserTest';
import fs from 'fs';
import * as path from 'path';
import { getUserAgent } from 'playwright-core/src/utils/utils';
import { getUserAgent } from 'playwright-core/lib/utils/utils';
import WebSocket from 'ws';
import { suppressCertificateWarning } from './config/utils';

Expand Down
2 changes: 1 addition & 1 deletion tests/chromium/chromium.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { contextTest as test, expect } from '../config/browserTest';
import { playwrightTest } from '../config/browserTest';
import http from 'http';
import { getUserAgent } from 'playwright-core/src/utils/utils';
import { getUserAgent } from 'playwright-core/lib/utils/utils';
import { suppressCertificateWarning } from '../config/utils';

test('should create a worker from a service worker', async ({ page, server }) => {
Expand Down
4 changes: 2 additions & 2 deletions tests/config/baseTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as path from 'path';
import * as fs from 'fs';
import { installCoverageHooks } from './coverage';
import { start } from '../../packages/playwright-core/lib/outofprocess';
import { GridClient } from 'playwright-core/src/grid/gridClient';
import { GridClient } from 'playwright-core/lib/grid/gridClient';
import type { LaunchOptions } from 'playwright-core';
import { commonFixtures, CommonFixtures, serverFixtures, ServerFixtures, ServerOptions } from './commonFixtures';

Expand Down Expand Up @@ -91,7 +91,7 @@ const baseFixtures: Fixtures<{}, BaseOptions & BaseFixtures> = {
service: new ServiceMode(),
driver: new DriverMode(),
}[mode];
require('playwright-core/src/utils/utils').setUnderTest();
require('playwright-core/lib/utils/utils').setUnderTest();
const playwright = await modeImpl.setup(workerInfo.workerIndex);
await run(playwright);
await modeImpl.teardown();
Expand Down
4 changes: 2 additions & 2 deletions tests/config/browserTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

import type { Fixtures } from '@playwright/test';
import type { Browser, BrowserContext, BrowserContextOptions, BrowserType, LaunchOptions, Page } from 'playwright-core';
import { removeFolders } from 'playwright-core/src/utils/utils';
import { removeFolders } from 'playwright-core/lib/utils/utils';
import { ReuseBrowserContextStorage } from '@playwright/test/src/index';
import * as path from 'path';
import * as fs from 'fs';
import * as os from 'os';
import { RemoteServer, RemoteServerOptions } from './remoteServer';
import { baseTest, CommonWorkerFixtures } from './baseTest';
import { CommonFixtures } from './commonFixtures';
import type { ParsedStackTrace } from 'playwright-core/src/utils/stackTrace';
import type { ParsedStackTrace } from 'playwright-core/lib/utils/stackTrace';

type PlaywrightWorkerOptions = {
executablePath: LaunchOptions['executablePath'];
Expand Down
2 changes: 1 addition & 1 deletion tests/global-fetch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import http from 'http';
import { getPlaywrightVersion } from 'playwright-core/src/utils/utils';
import { getPlaywrightVersion } from 'playwright-core/lib/utils/utils';
import { expect, playwrightTest as it } from './config/browserTest';

it.skip(({ mode }) => mode !== 'default');
Expand Down
2 changes: 1 addition & 1 deletion tests/har.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import fs from 'fs';
import http2 from 'http2';
import type { BrowserContext, BrowserContextOptions } from 'playwright-core';
import type { AddressInfo } from 'net';
import type { Log } from 'playwright-core/src/server/supplements/har/har';
import type { Log } from 'playwright-core/lib/server/supplements/har/har';

async function pageWithHar(contextFactory: (options?: BrowserContextOptions) => Promise<BrowserContext>, testInfo: any, outputPath: string = 'test.har') {
const harPath = testInfo.outputPath(outputPath);
Expand Down
2 changes: 1 addition & 1 deletion tests/inspector/inspectorTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { contextTest } from '../config/browserTest';
import type { Page } from 'playwright-core';
import * as path from 'path';
import type { Source } from 'playwright-core/src/server/supplements/recorder/recorderTypes';
import type { Source } from 'playwright-core/lib/server/supplements/recorder/recorderTypes';
import { CommonFixtures, TestChildProcess } from '../config/commonFixtures';
export { expect } from '@playwright/test';

Expand Down
2 changes: 1 addition & 1 deletion tests/playwright-test/playwright.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { test, expect, stripAscii } from './playwright-test-fixtures';
import fs from 'fs';
import path from 'path';
import { spawnSync } from 'child_process';
import { registry } from 'playwright-core/src/utils/registry';
import { registry } from 'playwright-core/lib/utils/registry';

const ffmpeg = registry.findExecutable('ffmpeg')!.executablePath();

Expand Down
4 changes: 4 additions & 0 deletions tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"strictBindCallApply": true,
"allowSyntheticDefaultImports": true,
"useUnknownInCatchVariables": false,
"baseUrl": ".",
"paths": {
"playwright-core/lib/*": ["../packages/playwright-core/src/*"]
},
},
"include": ["**/*.spec.js", "**/*.ts", "index.d.ts"],
"exclude": ["playwright-test/"]
Expand Down
2 changes: 1 addition & 1 deletion tests/video.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import fs from 'fs';
import path from 'path';
import { spawnSync } from 'child_process';
import { PNG } from 'pngjs';
import { registry } from 'playwright-core/src/utils/registry';
import { registry } from 'playwright-core/lib/utils/registry';

const ffmpeg = registry.findExecutable('ffmpeg')!.executablePath();

Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"lib": ["esnext", "dom", "DOM.Iterable"],
"baseUrl": ".",
"paths": {
"*": ["./packages/*/"]
"*": ["./packages/*/"],
"playwright-core/lib/*": ["./packages/playwright-core/src/*"]
},
"esModuleInterop": true,
"strict": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs');
const util = require('util');
const path = require('path');
const {spawn} = require('child_process');
const {registryDirectory} = require('playwright-core/src/utils/registry.js');
const {registryDirectory} = require('playwright-core/lib/utils/registry.js');

const readdirAsync = util.promisify(fs.readdir.bind(fs));
const readFileAsync = util.promisify(fs.readFile.bind(fs));
Expand Down

0 comments on commit 2b59574

Please sign in to comment.