Browse Source

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

Co-authored-by: Max Schmitt <max@schmitt.mx>
pull/8406/head
Joel Einbinder 2 weeks ago
committed by GitHub
parent
commit
c8f875a193
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      packages/playwright-test/index.d.ts
  2. 2
      packages/playwright-test/reporter.d.ts
  3. 2
      packages/playwright-test/src/dispatcher.ts
  4. 2
      packages/playwright-test/src/index.ts
  5. 2
      packages/playwright-test/src/ipc.ts
  6. 2
      packages/playwright-test/src/loader.ts
  7. 2
      packages/playwright-test/src/reporters/base.ts
  8. 2
      packages/playwright-test/src/reporters/dot.ts
  9. 2
      packages/playwright-test/src/reporters/empty.ts
  10. 2
      packages/playwright-test/src/reporters/github.ts
  11. 2
      packages/playwright-test/src/reporters/html.ts
  12. 2
      packages/playwright-test/src/reporters/json.ts
  13. 2
      packages/playwright-test/src/reporters/junit.ts
  14. 2
      packages/playwright-test/src/reporters/line.ts
  15. 2
      packages/playwright-test/src/reporters/list.ts
  16. 2
      packages/playwright-test/src/reporters/multiplexer.ts
  17. 4
      packages/playwright-test/src/reporters/raw.ts
  18. 2
      packages/playwright-test/src/runner.ts
  19. 4
      packages/playwright-test/src/test.ts
  20. 8
      packages/playwright-test/src/types.ts
  21. 2
      packages/playwright-test/src/webServer.ts
  22. 2
      packages/playwright-test/types/test.d.ts
  23. 0
      packages/playwright-test/types/testExpect.d.ts
  24. 0
      packages/playwright-test/types/testReporter.d.ts
  25. 2
      tests/browsertype-launch-selenium.spec.ts
  26. 17
      tests/config/test-runner.d.ts
  27. 17
      tests/config/test-runner.js
  28. 17
      utils/generate_types/index.js
  29. 2
      utils/generate_types/overrides-test.d.ts

4
packages/playwright-test/index.d.ts

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

2
packages/playwright-test/reporter.d.ts

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

2
packages/playwright-test/src/dispatcher.ts

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

2
packages/playwright-test/src/index.ts

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

2
packages/playwright-test/src/ipc.ts

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

2
packages/playwright-test/src/loader.ts

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

2
packages/playwright-test/src/reporters/base.ts

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

2
packages/playwright-test/src/reporters/dot.ts

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

2
packages/playwright-test/src/reporters/empty.ts

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

2
packages/playwright-test/src/reporters/github.ts

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

2
packages/playwright-test/src/reporters/html.ts

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

2
packages/playwright-test/src/reporters/json.ts

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

2
packages/playwright-test/src/reporters/junit.ts

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

2
packages/playwright-test/src/reporters/line.ts

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

2
packages/playwright-test/src/reporters/list.ts

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

2
packages/playwright-test/src/reporters/multiplexer.ts

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

4
packages/playwright-test/src/reporters/raw.ts

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

2
packages/playwright-test/src/runner.ts

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

4
packages/playwright-test/src/test.ts

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

8
packages/playwright-test/src/types.ts

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

2
packages/playwright-test/src/webServer.ts

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

2
packages/playwright-core/types/test.d.ts → packages/playwright-test/types/test.d.ts

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

0
packages/playwright-core/types/testExpect.d.ts → packages/playwright-test/types/testExpect.d.ts

0
packages/playwright-core/types/testReporter.d.ts → packages/playwright-test/types/testReporter.d.ts

2
tests/browsertype-launch-selenium.spec.ts

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

17
tests/config/test-runner.d.ts

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

17
tests/config/test-runner.js

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

17
utils/generate_types/index.js

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

2
utils/generate_types/overrides-test.d.ts

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

Loading…
Cancel
Save