chore: move test runner types into the playwright test package (#9472)

Co-authored-by: Max Schmitt <max@schmitt.mx>
This commit is contained in:
Joel Einbinder 2021-10-14 05:55:08 -04:00 committed by GitHub
parent 4fa6d1e723
commit c8f875a193
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 40 additions and 71 deletions

View File

@ -15,6 +15,6 @@
*/
export * from 'playwright-core';
export * from 'playwright-core/types/test';
export { default } from 'playwright-core/types/test';
export * from './types/test';
export { default } from './types/test';

View File

@ -14,4 +14,4 @@
* limitations under the License.
*/
export * from 'playwright-core/types/testReporter';
export * from './types/testReporter';

View File

@ -18,7 +18,7 @@ import child_process from 'child_process';
import path from 'path';
import { EventEmitter } from 'events';
import { RunPayload, TestBeginPayload, TestEndPayload, DonePayload, TestOutputPayload, WorkerInitParams, StepBeginPayload, StepEndPayload } from './ipc';
import type { TestResult, Reporter, TestStep } from 'playwright-core/types/testReporter';
import type { TestResult, Reporter, TestStep } from '../types/testReporter';
import { Suite, TestCase } from './test';
import { Loader } from './loader';

View File

@ -17,7 +17,7 @@
import * as fs from 'fs';
import * as path from 'path';
import type { LaunchOptions, BrowserContextOptions, Page, BrowserContext, BrowserType } from 'playwright-core';
import type { TestType, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, TestInfo } from 'playwright-core/types/test';
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';

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
import type { TestError } from 'playwright-core/types/testReporter';
import type { TestError } from '../types/testReporter';
import type { Config, TestStatus } from './types';
export type SerializedLoaderData = {

View File

@ -24,7 +24,7 @@ import * as path from 'path';
import * as url from 'url';
import * as fs from 'fs';
import { ProjectImpl } from './project';
import { Reporter } from 'playwright-core/types/testReporter';
import { Reporter } from '../types/testReporter';
import { BuiltInReporter, builtInReporters } from './runner';
import { isRegExp } from 'playwright-core/src/utils/utils';

View File

@ -20,7 +20,7 @@ import fs from 'fs';
import milliseconds from 'ms';
import path from 'path';
import StackUtils from 'stack-utils';
import { FullConfig, TestCase, Suite, TestResult, TestError, Reporter, FullResult, TestStep } from 'playwright-core/types/testReporter';
import { FullConfig, TestCase, Suite, TestResult, TestError, Reporter, FullResult, TestStep } from '../../types/testReporter';
const stackUtils = new StackUtils();

View File

@ -16,7 +16,7 @@
import colors from 'colors/safe';
import { BaseReporter } from './base';
import { FullResult, TestCase, TestResult } from 'playwright-core/types/testReporter';
import { FullResult, TestCase, TestResult } from '../../types/testReporter';
class DotReporter extends BaseReporter {
private _counter = 0;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
import { Reporter } from 'playwright-core/types/testReporter';
import { Reporter } from '../../types/testReporter';
class EmptyReporter implements Reporter {
}

View File

@ -17,7 +17,7 @@
import milliseconds from 'ms';
import path from 'path';
import { BaseReporter, formatFailure } from './base';
import { TestCase, FullResult } from 'playwright-core/types/testReporter';
import { TestCase, FullResult } from '../../types/testReporter';
type GitHubLogType = 'debug' | 'notice' | 'warning' | 'error';

View File

@ -18,7 +18,7 @@ import colors from 'colors/safe';
import fs from 'fs';
import open from 'open';
import path from 'path';
import { FullConfig, Suite } from 'playwright-core/types/testReporter';
import { FullConfig, Suite } from '../../types/testReporter';
import { HttpServer } from 'playwright-core/src/utils/httpServer';
import { calculateSha1, removeFolders } from 'playwright-core/src/utils/utils';
import { toPosixPath } from './json';

View File

@ -16,7 +16,7 @@
import fs from 'fs';
import path from 'path';
import { FullConfig, TestCase, Suite, TestResult, TestError, TestStep, FullResult, TestStatus, Location, Reporter } from 'playwright-core/types/testReporter';
import { FullConfig, TestCase, Suite, TestResult, TestError, TestStep, FullResult, TestStatus, Location, Reporter } from '../../types/testReporter';
import { PositionInFile, prepareErrorStack } from './base';
export interface JSONReport {

View File

@ -16,7 +16,7 @@
import fs from 'fs';
import path from 'path';
import { FullConfig, FullResult, Reporter, Suite, TestCase } from 'playwright-core/types/testReporter';
import { FullConfig, FullResult, Reporter, Suite, TestCase } from '../../types/testReporter';
import { monotonicTime } from '../util';
import { formatFailure, formatTestTitle, stripAnsiEscapes } from './base';

View File

@ -16,7 +16,7 @@
import colors from 'colors/safe';
import { BaseReporter, formatFailure, formatTestTitle } from './base';
import { FullConfig, TestCase, Suite, TestResult, FullResult } from 'playwright-core/types/testReporter';
import { FullConfig, TestCase, Suite, TestResult, FullResult } from '../../types/testReporter';
class LineReporter extends BaseReporter {
private _total = 0;

View File

@ -18,7 +18,7 @@
import colors from 'colors/safe';
import milliseconds from 'ms';
import { BaseReporter, formatTestTitle } from './base';
import { FullConfig, FullResult, Suite, TestCase, TestResult, TestStep } from 'playwright-core/types/testReporter';
import { FullConfig, FullResult, Suite, TestCase, TestResult, TestStep } from '../../types/testReporter';
// Allow it in the Visual Studio Code Terminal and the new Windows Terminal
const DOES_NOT_SUPPORT_UTF8_IN_TERMINAL = process.platform === 'win32' && process.env.TERM_PROGRAM !== 'vscode' && !process.env.WT_SESSION;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
import { FullConfig, Suite, TestCase, TestError, TestResult, Reporter, FullResult, TestStep } from 'playwright-core/types/testReporter';
import { FullConfig, Suite, TestCase, TestError, TestResult, Reporter, FullResult, TestStep } from '../../types/testReporter';
export class Multiplexer implements Reporter {
private _reporters: Reporter[];

View File

@ -16,8 +16,8 @@
import fs from 'fs';
import path from 'path';
import { FullProject } from 'playwright-core/types/test';
import { FullConfig, Location, Suite, TestCase, TestResult, TestStatus, TestStep } from 'playwright-core/types/testReporter';
import { FullProject } from '../types';
import { FullConfig, Location, Suite, TestCase, TestResult, TestStatus, TestStep } from '../../types/testReporter';
import { assert, calculateSha1 } from 'playwright-core/src/utils/utils';
import { sanitizeForFilePath } from '../util';
import { formatResultFailure } from './base';

View File

@ -24,7 +24,7 @@ import { Dispatcher, TestGroup } from './dispatcher';
import { createFileMatcher, createTitleMatcher, FilePatternFilter, monotonicTime } from './util';
import { TestCase, Suite } from './test';
import { Loader } from './loader';
import { Reporter } from 'playwright-core/types/testReporter';
import { Reporter } from '../types/testReporter';
import { Multiplexer } from './reporters/multiplexer';
import DotReporter from './reporters/dot';
import GitHubReporter from './reporters/github';

View File

@ -15,10 +15,10 @@
*/
import type { FixturePool } from './fixtures';
import * as reporterTypes from 'playwright-core/types/testReporter';
import * as reporterTypes from '../types/testReporter';
import type { TestTypeImpl } from './testType';
import { Annotations, FixturesWithLocation, Location } from './types';
import { FullProject } from 'playwright-core/types/test';
import { FullProject } from './types';
class Base {
title: string;

View File

@ -14,10 +14,10 @@
* limitations under the License.
*/
import type { Fixtures, TestError, TestInfo } from 'playwright-core/types/test';
import type { Location } from 'playwright-core/types/testReporter';
export * from 'playwright-core/types/test';
export { Location } from 'playwright-core/types/testReporter';
import type { Fixtures, TestError, TestInfo } from '../types/test';
import type { Location } from '../types/testReporter';
export * from '../types/test';
export { Location } from '../types/testReporter';
export type FixturesWithLocation = {
fixtures: Fixtures;

View File

@ -19,7 +19,7 @@ import os from 'os';
import stream from 'stream';
import { monotonicTime } from './util';
import { raceAgainstDeadline } from 'playwright-core/src/utils/async';
import { WebServerConfig } from 'playwright-core/types/test';
import { WebServerConfig } from './types';
import { launchProcess } from 'playwright-core/src/utils/processLauncher';
const DEFAULT_ENVIRONMENT_VARIABLES = {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import type { ApiRequestContext, Browser, BrowserContext, BrowserContextOptions, Page, LaunchOptions, ViewportSize, Geolocation, HTTPCredentials } from './types';
import type { ApiRequestContext, Browser, BrowserContext, BrowserContextOptions, Page, LaunchOptions, ViewportSize, Geolocation, HTTPCredentials } from 'playwright-core';
import type { Expect } from './testExpect';
export type { Expect } from './testExpect';

View File

@ -15,7 +15,7 @@
*/
import { playwrightTest as test, expect } from './config/browserTest';
import type { TestInfo } from 'playwright-core/types/test';
import type { TestInfo } from '@playwright/test';
import path from 'path';
import fs from 'fs';
import { start } from 'playwright-core/lib/outofprocess';

View File

@ -1,17 +0,0 @@
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from 'playwright-core/types/test';

View File

@ -1,17 +0,0 @@
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('@playwright/test');

View File

@ -469,10 +469,13 @@ class TypesGenerator {
fs.writeFileSync(filePath, content, 'utf8');
}
const typesDir = path.join(PROJECT_DIR, 'packages', 'playwright-core', 'types');
if (!fs.existsSync(typesDir))
fs.mkdirSync(typesDir)
writeFile(path.join(typesDir, 'protocol.d.ts'), fs.readFileSync(path.join(PROJECT_DIR, 'packages', 'playwright-core', 'src', 'server', 'chromium', 'protocol.d.ts'), 'utf8'));
const coreTypesDir = path.join(PROJECT_DIR, 'packages', 'playwright-core', 'types');
if (!fs.existsSync(coreTypesDir))
fs.mkdirSync(coreTypesDir)
const testTypesDir = path.join(PROJECT_DIR, 'packages', 'playwright-test', 'types');
if (!fs.existsSync(testTypesDir))
fs.mkdirSync(testTypesDir)
writeFile(path.join(coreTypesDir, 'protocol.d.ts'), fs.readFileSync(path.join(PROJECT_DIR, 'packages', 'playwright-core', 'src', 'server', 'chromium', 'protocol.d.ts'), 'utf8'));
const apiDocumentation = parseApi(path.join(PROJECT_DIR, 'docs', 'src', 'api'));
apiDocumentation.index();
@ -495,7 +498,7 @@ class TypesGenerator {
for (const [key, value] of Object.entries(exported))
apiTypes = apiTypes.replace(new RegExp('\\b' + key + '\\b', 'g'), value);
apiTypes = apiTypes.replace(/( +)\n/g, '\n'); // remove trailing whitespace
writeFile(path.join(typesDir, 'types.d.ts'), apiTypes);
writeFile(path.join(coreTypesDir, 'types.d.ts'), apiTypes);
const testOnlyDocumentation = parseApi(path.join(PROJECT_DIR, 'docs', 'src', 'test-api'), path.join(PROJECT_DIR, 'docs', 'src', 'api', 'params.md'));
const testDocumentation = apiDocumentation.mergeWith(testOnlyDocumentation);
@ -512,14 +515,14 @@ class TypesGenerator {
]);
let testTypes = await testTypesGenerator.generateTypes(path.join(__dirname, 'overrides-test.d.ts'), testClassMapping);
testTypes = testTypes.replace(/( +)\n/g, '\n'); // remove trailing whitespace
writeFile(path.join(typesDir, 'test.d.ts'), testTypes);
writeFile(path.join(testTypesDir, 'test.d.ts'), testTypes);
const testReporterOnlyDocumentation = parseApi(path.join(PROJECT_DIR, 'docs', 'src', 'test-reporter-api'));
const testReporterDocumentation = testDocumentation.mergeWith(testReporterOnlyDocumentation);
const testReporterTypesGenerator = new TypesGenerator(testReporterDocumentation);
let testReporterTypes = await testReporterTypesGenerator.generateTypes(path.join(__dirname, 'overrides-testReporter.d.ts'), new Map());
testReporterTypes = testReporterTypes.replace(/( +)\n/g, '\n'); // remove trailing whitespace
writeFile(path.join(typesDir, 'testReporter.d.ts'), testReporterTypes);
writeFile(path.join(testTypesDir, 'testReporter.d.ts'), testReporterTypes);
process.exit(hadChanges && process.argv.includes('--check-clean') ? 1 : 0);
})().catch(e => {

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
import type { ApiRequestContext, Browser, BrowserContext, BrowserContextOptions, Page, LaunchOptions, ViewportSize, Geolocation, HTTPCredentials } from './types';
import type { ApiRequestContext, Browser, BrowserContext, BrowserContextOptions, Page, LaunchOptions, ViewportSize, Geolocation, HTTPCredentials } from 'playwright-core';
import type { Expect } from './testExpect';
export type { Expect } from './testExpect';