fix: support even older node 12 (#9718)

This commit is contained in:
Joel Einbinder 2021-10-22 15:59:52 -04:00 коммит произвёл GitHub
Родитель 193c79a685
Коммит f2888395a6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
32 изменённых файлов: 54 добавлений и 48 удалений

1
.github/workflows/tests_secondary.yml поставляемый
Просмотреть файл

@ -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"

Просмотреть файл

@ -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);

Просмотреть файл

@ -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']);

Просмотреть файл

@ -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": {

Просмотреть файл

@ -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']);

Просмотреть файл

@ -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';

Просмотреть файл

@ -21,7 +21,7 @@ import { RunPayload, TestBeginPayload, TestEndPayload, DonePayload, TestOutputPa
import type { TestResult, Reporter, TestStep } from '../types/testReporter';
import { Suite, TestCase } from './test';
import { Loader } from './loader';
import { ManualPromise } from 'playwright-core/src/utils/async';
import { ManualPromise } from 'playwright-core/lib/utils/async';
export type TestGroup = {
workerHash: string;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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';

Просмотреть файл

@ -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';

Просмотреть файл

@ -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';

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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

Просмотреть файл

@ -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);

Просмотреть файл

@ -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']);

Просмотреть файл

@ -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();

Просмотреть файл

@ -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';

Просмотреть файл

@ -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 }) => {

Просмотреть файл

@ -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';
@ -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();

Просмотреть файл

@ -16,7 +16,7 @@
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';
@ -24,7 +24,7 @@ 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'];

Просмотреть файл

@ -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');

Просмотреть файл

@ -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);

Просмотреть файл

@ -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';

Просмотреть файл

@ -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();

Просмотреть файл

@ -17,7 +17,7 @@
import fs from 'fs';
import path from 'path';
import { test as baseTest, expect } from './playwright-test-fixtures';
import { HttpServer } from 'playwright-core/src/utils/httpServer';
import { HttpServer } from 'playwright-core/lib/utils/httpServer';
const test = baseTest.extend<{ showReport: () => Promise<void> }>({
showReport: async ({ page }, use, testInfo) => {

Просмотреть файл

@ -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/"]

Просмотреть файл

@ -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();

Просмотреть файл

@ -5,7 +5,8 @@
"lib": ["esnext", "dom", "DOM.Iterable"],
"baseUrl": ".",
"paths": {
"*": ["./packages/*/"]
"*": ["./packages/*/"],
"playwright-core/lib/*": ["./packages/playwright-core/src/*"]
},
"esModuleInterop": true,
"strict": true,

Просмотреть файл

@ -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));