Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

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

Joel Einbinderc8f875a1939d
diff --git a/packages/playwright-test/index.d.ts b/packages/playwright-test/index.d.ts
index 919358305d..cd6ece8f42 100644
--- a/packages/playwright-test/index.d.ts
+++ b/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';
\ No newline at end of file
diff --git a/packages/playwright-test/reporter.d.ts b/packages/playwright-test/reporter.d.ts
index b59dcc116c..29a927d48e 100644
--- a/packages/playwright-test/reporter.d.ts
+++ b/packages/playwright-test/reporter.d.ts
@@ -14,4 +14,4 @@
* limitations under the License.
*/
-export * from 'playwright-core/types/testReporter';
+export * from './types/testReporter';
diff --git a/packages/playwright-test/src/dispatcher.ts b/packages/playwright-test/src/dispatcher.ts
index 531573c35c..c8f379dc5d 100644
--- a/packages/playwright-test/src/dispatcher.ts
+++ b/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';
diff --git a/packages/playwright-test/src/index.ts b/packages/playwright-test/src/index.ts
index bbb6f8e751..6b1078b88f 100644
--- a/packages/playwright-test/src/index.ts
+++ b/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';
diff --git a/packages/playwright-test/src/ipc.ts b/packages/playwright-test/src/ipc.ts
index bff9ec0618..e0af4ec9c0 100644
--- a/packages/playwright-test/src/ipc.ts
+++ b/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 = {
diff --git a/packages/playwright-test/src/loader.ts b/packages/playwright-test/src/loader.ts
index fb7a5b253a..0163a0ffe4 100644
--- a/packages/playwright-test/src/loader.ts
+++ b/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';
diff --git a/packages/playwright-test/src/reporters/base.ts b/packages/playwright-test/src/reporters/base.ts
index 7b57de5cb9..2e5d52aa78 100644
--- a/packages/playwright-test/src/reporters/base.ts
+++ b/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();
diff --git a/packages/playwright-test/src/reporters/dot.ts b/packages/playwright-test/src/reporters/dot.ts
index 896cf77d39..0175b82607 100644
--- a/packages/playwright-test/src/reporters/dot.ts
+++ b/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;
diff --git a/packages/playwright-test/src/reporters/empty.ts b/packages/playwright-test/src/reporters/empty.ts
index 0bcec667ac..921c8ac4d2 100644
--- a/packages/playwright-test/src/reporters/empty.ts
+++ b/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 {
}
diff --git a/packages/playwright-test/src/reporters/github.ts b/packages/playwright-test/src/reporters/github.ts
index e59067daed..c5d344bb5e 100644
--- a/packages/playwright-test/src/reporters/github.ts
+++ b/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';
diff --git a/packages/playwright-test/src/reporters/html.ts b/packages/playwright-test/src/reporters/html.ts
index dafef1eae8..55d6d8f333 100644
--- a/packages/playwright-test/src/reporters/html.ts
+++ b/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';
diff --git a/packages/playwright-test/src/reporters/json.ts b/packages/playwright-test/src/reporters/json.ts
index b321719f17..8ed09a705e 100644
--- a/packages/playwright-test/src/reporters/json.ts
+++ b/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 {
diff --git a/packages/playwright-test/src/reporters/junit.ts b/packages/playwright-test/src/reporters/junit.ts
index d995d3fadf..d491d99139 100644
--- a/packages/playwright-test/src/reporters/junit.ts
+++ b/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';
diff --git a/packages/playwright-test/src/reporters/line.ts b/packages/playwright-test/src/reporters/line.ts
index 77420e7a46..1caed2c43e 100644
--- a/packages/playwright-test/src/reporters/line.ts
+++ b/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;
diff --git a/packages/playwright-test/src/reporters/list.ts b/packages/playwright-test/src/reporters/list.ts
index 39b2b41969..4b855457cb 100644
--- a/packages/playwright-test/src/reporters/list.ts
+++ b/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;
diff --git a/packages/playwright-test/src/reporters/multiplexer.ts b/packages/playwright-test/src/reporters/multiplexer.ts
index f996d8d34b..54bb789dfe 100644
--- a/packages/playwright-test/src/reporters/multiplexer.ts
+++ b/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[];
diff --git a/packages/playwright-test/src/reporters/raw.ts b/packages/playwright-test/src/reporters/raw.ts
index 9eb8dc6b11..004fc6a00e 100644
--- a/packages/playwright-test/src/reporters/raw.ts
+++ b/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';
diff --git a/packages/playwright-test/src/runner.ts b/packages/playwright-test/src/runner.ts
index 2692e8d920..34a4862969 100644
--- a/packages/playwright-test/src/runner.ts
+++ b/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';
diff --git a/packages/playwright-test/src/test.ts b/packages/playwright-test/src/test.ts
index 4f72a8d9d9..a4503d8ad3 100644
--- a/packages/playwright-test/src/test.ts
+++ b/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;
diff --git a/packages/playwright-test/src/types.ts b/packages/playwright-test/src/types.ts
index ed7ffd7d1e..df533e85a0 100644
--- a/packages/playwright-test/src/types.ts
+++ b/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;
diff --git a/packages/playwright-test/src/webServer.ts b/packages/playwright-test/src/webServer.ts
index 7d6fa78565..caeebefe09 100644
--- a/packages/playwright-test/src/webServer.ts
+++ b/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 = {
diff --git a/packages/playwright-core/types/test.d.ts b/packages/playwright-test/types/test.d.ts
similarity index 99%
rename from packages/playwright-core/types/test.d.ts
rename to packages/playwright-test/types/test.d.ts
index 13452d0757..64a4b8173c 100644
--- a/packages/playwright-core/types/test.d.ts
+++ b/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';
diff --git a/packages/playwright-core/types/testExpect.d.ts b/packages/playwright-test/types/testExpect.d.ts
similarity index 100%
rename from packages/playwright-core/types/testExpect.d.ts
rename to packages/playwright-test/types/testExpect.d.ts
diff --git a/packages/playwright-core/types/testReporter.d.ts b/packages/playwright-test/types/testReporter.d.ts
similarity index 100%
rename from packages/playwright-core/types/testReporter.d.ts
rename to packages/playwright-test/types/testReporter.d.ts
diff --git a/tests/browsertype-launch-selenium.spec.ts b/tests/browsertype-launch-selenium.spec.ts
index c2c5560326..9f03338bc5 100644
--- a/tests/browsertype-launch-selenium.spec.ts
+++ b/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';
diff --git a/tests/config/test-runner.d.ts b/tests/config/test-runner.d.ts
deleted file mode 100644
index 7dc4a48bc9..0000000000
--- a/tests/config/test-runner.d.ts
+++ /dev/null
@@ -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';
diff --git a/tests/config/test-runner.js b/tests/config/test-runner.js
deleted file mode 100644
index 1c932e7b82..0000000000
--- a/tests/config/test-runner.js
+++ /dev/null
@@ -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');
diff --git a/utils/generate_types/index.js b/utils/generate_types/index.js
index e7a60615e4..13f3d1c2b7 100644
--- a/utils/generate_types/index.js
+++ b/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 => {
diff --git a/utils/generate_types/overrides-test.d.ts b/utils/generate_types/overrides-test.d.ts
index fed889c104..4f85891355 100644
--- a/utils/generate_types/overrides-test.d.ts
+++ b/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';