diff --git a/docs/src/auth.md b/docs/src/auth.md index 4a3853edf1..19c97c7c43 100644 --- a/docs/src/auth.md +++ b/docs/src/auth.md @@ -47,7 +47,7 @@ Create `tests/auth.setup.ts` that will prepare authenticated browser state for a ```js title="tests/auth.setup.ts" import { test as setup, expect } from '@playwright/test'; -import path from 'path'; +import * as path from 'path'; const authFile = path.join(__dirname, '../playwright/.auth/user.json'); @@ -143,8 +143,8 @@ Create `playwright/fixtures.ts` file that will [override `storageState` fixture] ```js title="playwright/fixtures.ts" import { test as baseTest, expect } from '@playwright/test'; -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; export * from '@playwright/test'; export const test = baseTest.extend<{}, { workerStorageState: string }>({ @@ -348,8 +348,8 @@ Alternatively, in a [worker fixture](#moderate-one-account-per-parallel-worker): ```js title="playwright/fixtures.ts" import { test as baseTest, request } from '@playwright/test'; -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; export * from '@playwright/test'; export const test = baseTest.extend<{}, { workerStorageState: string }>({ diff --git a/docs/src/chrome-extensions-js-python.md b/docs/src/chrome-extensions-js-python.md index 5cabc1c864..3ac6692f16 100644 --- a/docs/src/chrome-extensions-js-python.md +++ b/docs/src/chrome-extensions-js-python.md @@ -109,7 +109,7 @@ First, add fixtures that will load the extension: ```js title="fixtures.ts" import { test as base, chromium, type BrowserContext } from '@playwright/test'; -import path from 'path'; +import * as path from 'path'; export const test = base.extend<{ context: BrowserContext; diff --git a/docs/src/evaluating.md b/docs/src/evaluating.md index 903aeb8a90..d1ee75b8a8 100644 --- a/docs/src/evaluating.md +++ b/docs/src/evaluating.md @@ -389,7 +389,7 @@ Next, add init script to the page. ```js import { test, expect } from '@playwright/test'; -import path from 'path'; +import * as path from 'path'; test.beforeEach(async ({ page }) => { // Add script for every test in the beforeEach hook. diff --git a/docs/src/test-api/class-testconfig.md b/docs/src/test-api/class-testconfig.md index c57789a82b..5b89e62b88 100644 --- a/docs/src/test-api/class-testconfig.md +++ b/docs/src/test-api/class-testconfig.md @@ -291,7 +291,7 @@ Here is an example that uses [`method: TestInfo.outputPath`] to create a tempora ```js import { test, expect } from '@playwright/test'; -import fs from 'fs'; +import * as fs from 'fs'; test('example test', async ({}, testInfo) => { const file = testInfo.outputPath('temporary-file.txt'); diff --git a/docs/src/test-api/class-testinfo.md b/docs/src/test-api/class-testinfo.md index 93cbc93b75..b612699db6 100644 --- a/docs/src/test-api/class-testinfo.md +++ b/docs/src/test-api/class-testinfo.md @@ -254,7 +254,7 @@ Returns a path inside the [`property: TestInfo.outputDir`] where the test can sa ```js import { test, expect } from '@playwright/test'; -import fs from 'fs'; +import * as fs from 'fs'; test('example test', async ({}, testInfo) => { const file = testInfo.outputPath('dir', 'temporary-file.txt'); diff --git a/docs/src/test-api/class-testproject.md b/docs/src/test-api/class-testproject.md index 17fecf6930..e0dda139a3 100644 --- a/docs/src/test-api/class-testproject.md +++ b/docs/src/test-api/class-testproject.md @@ -212,7 +212,7 @@ Here is an example that uses [`method: TestInfo.outputPath`] to create a tempora ```js import { test, expect } from '@playwright/test'; -import fs from 'fs'; +import * as fs from 'fs'; test('example test', async ({}, testInfo) => { const file = testInfo.outputPath('temporary-file.txt'); diff --git a/docs/src/test-parameterize-js.md b/docs/src/test-parameterize-js.md index 7575f96695..8670006833 100644 --- a/docs/src/test-parameterize-js.md +++ b/docs/src/test-parameterize-js.md @@ -262,7 +262,7 @@ To make environment variables easier to manage, consider something like `.env` f ```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; import dotenv from 'dotenv'; -import path from 'path'; +import * as path from 'path'; // Read from ".env" file. dotenv.config({ path: path.resolve(__dirname, '.env') }); @@ -309,8 +309,8 @@ See for example this CSV file, in our example `input.csv`: Based on this we'll generate some tests by using the [csv-parse](https://www.npmjs.com/package/csv-parse) library from NPM: ```js title="test.spec.ts" -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; import { test } from '@playwright/test'; import { parse } from 'csv-parse/sync'; diff --git a/docs/src/webview2.md b/docs/src/webview2.md index 7aef7216ca..81a9f698ad 100644 --- a/docs/src/webview2.md +++ b/docs/src/webview2.md @@ -72,9 +72,9 @@ Using the following, Playwright will run your WebView2 application as a sub-proc ```js title="webView2Test.ts" import { test as base } from '@playwright/test'; -import fs from 'fs'; -import os from 'os'; -import path from 'path'; +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; import childProcess from 'child_process'; const EXECUTABLE_PATH = path.join( diff --git a/eslint.config.mjs b/eslint.config.mjs index 97b29eb05f..d47653345e 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -233,7 +233,9 @@ export default [{ }], } }, { - files: ['packages/playwright-core/**/*.ts'], + files: [ + 'packages/**/*.ts', + ], rules: { ...importOrderRules }, diff --git a/packages/html-reporter/bundle.ts b/packages/html-reporter/bundle.ts index 63530cfaad..cb85f309d8 100644 --- a/packages/html-reporter/bundle.ts +++ b/packages/html-reporter/bundle.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; import type { Plugin, UserConfig } from 'vite'; export function bundle(): Plugin { diff --git a/packages/html-reporter/playwright.config.ts b/packages/html-reporter/playwright.config.ts index 1e6cb8b8a3..d2160cd009 100644 --- a/packages/html-reporter/playwright.config.ts +++ b/packages/html-reporter/playwright.config.ts @@ -15,8 +15,8 @@ */ import { devices, defineConfig } from '@playwright/experimental-ct-react'; -import path from 'path'; -import url from 'url'; +import * as path from 'path'; +import * as url from 'url'; export default defineConfig({ testDir: 'src', diff --git a/packages/playwright-ct-core/src/devServer.ts b/packages/playwright-ct-core/src/devServer.ts index 2152a672b3..e93a633b1b 100644 --- a/packages/playwright-ct-core/src/devServer.ts +++ b/packages/playwright-ct-core/src/devServer.ts @@ -14,14 +14,17 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; + import { Watcher } from 'playwright/lib/fsWatcher'; -import type { PluginContext } from 'rollup'; + import { source as injectedSource } from './generated/indexSource'; -import { createConfig, populateComponentsFromTests, resolveDirs, transformIndexFile, frameworkConfig } from './viteUtils'; +import { createConfig, frameworkConfig, populateComponentsFromTests, resolveDirs, transformIndexFile } from './viteUtils'; + import type { ComponentRegistry } from './viteUtils'; import type { FullConfig } from 'playwright/test'; +import type { PluginContext } from 'rollup'; export async function runDevServer(config: FullConfig): Promise<() => Promise> { const { registerSourceFile, frameworkPluginFactory } = frameworkConfig(config); diff --git a/packages/playwright-ct-core/src/mount.ts b/packages/playwright-ct-core/src/mount.ts index a3bcfe0641..68a2468c35 100644 --- a/packages/playwright-ct-core/src/mount.ts +++ b/packages/playwright-ct-core/src/mount.ts @@ -14,13 +14,14 @@ * limitations under the License. */ -import type { Fixtures, Locator, Page, BrowserContextOptions, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, BrowserContext } from 'playwright/test'; -import type { Component, JsxComponent, MountOptions, ObjectComponentOptions } from '../types/component'; -import type { ContextReuseMode, FullConfigInternal } from '../../playwright/src/common/config'; -import type { ImportRef } from './injected/importRegistry'; import { wrapObject } from './injected/serializers'; import { Router } from './router'; + +import type { ContextReuseMode, FullConfigInternal } from '../../playwright/src/common/config'; import type { RouterFixture } from '../index'; +import type { ImportRef } from './injected/importRegistry'; +import type { Component, JsxComponent, MountOptions, ObjectComponentOptions } from '../types/component'; +import type { BrowserContext, BrowserContextOptions, Fixtures, Locator, Page, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions } from 'playwright/test'; let boundCallbacksForMount: Function[] = []; diff --git a/packages/playwright-ct-core/src/tsxTransform.ts b/packages/playwright-ct-core/src/tsxTransform.ts index 0af7c181b9..ece6dbccd0 100644 --- a/packages/playwright-ct-core/src/tsxTransform.ts +++ b/packages/playwright-ct-core/src/tsxTransform.ts @@ -14,10 +14,12 @@ * limitations under the License. */ -import path from 'path'; -import type { T, BabelAPI, PluginObj } from 'playwright/src/transform/babelBundle'; -import { types, declare, traverse } from 'playwright/lib/transform/babelBundle'; +import * as path from 'path'; + +import { declare, traverse, types } from 'playwright/lib/transform/babelBundle'; import { setTransformData } from 'playwright/lib/transform/transform'; + +import type { BabelAPI, PluginObj, T } from 'playwright/src/transform/babelBundle'; const t: typeof T = types; let jsxComponentNames: Set; diff --git a/packages/playwright-ct-core/src/vitePlugin.ts b/packages/playwright-ct-core/src/vitePlugin.ts index ec738c8700..038143cdb8 100644 --- a/packages/playwright-ct-core/src/vitePlugin.ts +++ b/packages/playwright-ct-core/src/vitePlugin.ts @@ -14,25 +14,29 @@ * limitations under the License. */ -import fs from 'fs'; -import type http from 'http'; -import type { AddressInfo } from 'net'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; + +import { setExternalDependencies } from 'playwright/lib/transform/compilationCache'; +import { resolveHook } from 'playwright/lib/transform/transform'; +import { removeDirAndLogToConsole } from 'playwright/lib/util'; +import { stoppable } from 'playwright/lib/utilsBundle'; import { assert, calculateSha1, getPlaywrightVersion, isURLAvailable } from 'playwright-core/lib/utils'; import { debug } from 'playwright-core/lib/utilsBundle'; -import { setExternalDependencies } from 'playwright/lib/transform/compilationCache'; -import { stoppable } from 'playwright/lib/utilsBundle'; + +import { runDevServer } from './devServer'; +import { source as injectedSource } from './generated/indexSource'; +import { createConfig, frameworkConfig, hasJSComponents, populateComponentsFromTests, resolveDirs, resolveEndpoint, transformIndexFile } from './viteUtils'; + +import type { ImportInfo } from './tsxTransform'; +import type { ComponentRegistry } from './viteUtils'; +import type { TestRunnerPlugin } from '../../playwright/src/plugins'; +import type http from 'http'; +import type { AddressInfo } from 'net'; import type { FullConfig, Suite } from 'playwright/types/testReporter'; import type { PluginContext } from 'rollup'; import type { Plugin, ResolveFn, ResolvedConfig } from 'vite'; -import type { TestRunnerPlugin } from '../../playwright/src/plugins'; -import { source as injectedSource } from './generated/indexSource'; -import type { ImportInfo } from './tsxTransform'; -import type { ComponentRegistry } from './viteUtils'; -import { createConfig, frameworkConfig, hasJSComponents, populateComponentsFromTests, resolveDirs, resolveEndpoint, transformIndexFile } from './viteUtils'; -import { resolveHook } from 'playwright/lib/transform/transform'; -import { runDevServer } from './devServer'; -import { removeDirAndLogToConsole } from 'playwright/lib/util'; + const log = debug('pw:vite'); diff --git a/packages/playwright-ct-core/src/viteUtils.ts b/packages/playwright-ct-core/src/viteUtils.ts index a9f7020999..5873ad4bf0 100644 --- a/packages/playwright-ct-core/src/viteUtils.ts +++ b/packages/playwright-ct-core/src/viteUtils.ts @@ -14,15 +14,18 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import { debug } from 'playwright-core/lib/utilsBundle'; +import * as fs from 'fs'; +import * as path from 'path'; + import { getUserData } from 'playwright/lib/transform/compilationCache'; +import { resolveHook } from 'playwright/lib/transform/transform'; +import { debug } from 'playwright-core/lib/utilsBundle'; + +import type { ImportInfo } from './tsxTransform'; import type { PlaywrightTestConfig as BasePlaywrightTestConfig } from 'playwright/types/test'; import type { FullConfig } from 'playwright/types/testReporter'; import type { InlineConfig, Plugin, TransformResult, UserConfig } from 'vite'; -import type { ImportInfo } from './tsxTransform'; -import { resolveHook } from 'playwright/lib/transform/transform'; + const log = debug('pw:vite'); diff --git a/packages/playwright-tools/src/examples/browser-anthropic.ts b/packages/playwright-tools/src/examples/browser-anthropic.ts index 0053c5749d..d7dd750a18 100644 --- a/packages/playwright-tools/src/examples/browser-anthropic.ts +++ b/packages/playwright-tools/src/examples/browser-anthropic.ts @@ -16,10 +16,10 @@ /* eslint-disable no-console */ -import playwright from 'playwright'; import Anthropic from '@anthropic-ai/sdk'; -import dotenv from 'dotenv'; import browser from '@playwright/experimental-tools/browser'; +import dotenv from 'dotenv'; +import playwright from 'playwright'; dotenv.config(); diff --git a/packages/playwright-tools/src/examples/browser-openai.ts b/packages/playwright-tools/src/examples/browser-openai.ts index 3542d4ba1d..c3f1752d78 100644 --- a/packages/playwright-tools/src/examples/browser-openai.ts +++ b/packages/playwright-tools/src/examples/browser-openai.ts @@ -16,10 +16,11 @@ /* eslint-disable no-console */ -import playwright from 'playwright'; import browser from '@playwright/experimental-tools/browser'; import dotenv from 'dotenv'; import OpenAI from 'openai'; +import playwright from 'playwright'; + import type { ChatCompletionMessageParam, ChatCompletionTool } from 'openai/resources'; dotenv.config(); diff --git a/packages/playwright-tools/src/examples/computer-20241022-anthropic.ts b/packages/playwright-tools/src/examples/computer-20241022-anthropic.ts index 20028c564c..2d8ee4b7f9 100644 --- a/packages/playwright-tools/src/examples/computer-20241022-anthropic.ts +++ b/packages/playwright-tools/src/examples/computer-20241022-anthropic.ts @@ -16,11 +16,13 @@ /* eslint-disable no-console */ -import playwright from 'playwright'; import Anthropic from '@anthropic-ai/sdk'; +import computer from '@playwright/experimental-tools/computer-20241022'; import dotenv from 'dotenv'; -import computer, { type ToolResult } from '@playwright/experimental-tools/computer-20241022'; +import playwright from 'playwright'; + import type { BetaImageBlockParam, BetaTextBlockParam } from '@anthropic-ai/sdk/resources/beta/messages/messages'; +import type { ToolResult } from '@playwright/experimental-tools/computer-20241022'; dotenv.config(); diff --git a/packages/playwright-tools/src/tools/browser.ts b/packages/playwright-tools/src/tools/browser.ts index 4b63487942..1ca7fb074a 100644 --- a/packages/playwright-tools/src/tools/browser.ts +++ b/packages/playwright-tools/src/tools/browser.ts @@ -15,11 +15,13 @@ * limitations under the License. */ -import type playwright from 'playwright'; -import type { JSONSchemaType, ToolDeclaration } from '../../types'; -import type { ToolResult } from '../../browser'; import { waitForNetwork } from './utils'; +import type { ToolResult } from '../../browser'; +import type { JSONSchemaType, ToolDeclaration } from '../../types'; +import type playwright from 'playwright'; + + type LocatorEx = playwright.Locator & { _generateLocatorString: () => Promise; }; diff --git a/packages/playwright-tools/src/tools/computer-20241022.ts b/packages/playwright-tools/src/tools/computer-20241022.ts index e407d027ba..2a7574c485 100644 --- a/packages/playwright-tools/src/tools/computer-20241022.ts +++ b/packages/playwright-tools/src/tools/computer-20241022.ts @@ -15,11 +15,13 @@ * limitations under the License. */ -import type playwright from 'playwright'; -import type { JSONSchemaType } from '../../types'; -import type { ToolResult } from '../../computer-20241022'; import { waitForNetwork } from './utils'; +import type { ToolResult } from '../../computer-20241022'; +import type { JSONSchemaType } from '../../types'; +import type playwright from 'playwright'; + + export async function call(page: playwright.Page, toolName: string, input: Record): Promise { if (toolName !== 'computer') throw new Error('Unsupported tool'); diff --git a/packages/playwright-tools/src/tools/utils.ts b/packages/playwright-tools/src/tools/utils.ts index 08e674014d..71c49e4fe1 100644 --- a/packages/playwright-tools/src/tools/utils.ts +++ b/packages/playwright-tools/src/tools/utils.ts @@ -15,9 +15,10 @@ * limitations under the License. */ -import type playwright from 'playwright'; import { ManualPromise } from 'playwright-core/lib/utils'; +import type playwright from 'playwright'; + export async function waitForNetwork(page: playwright.Page, callback: () => Promise): Promise { const requests = new Set(); let frameNavigated = false; diff --git a/packages/playwright/bundles/babel/src/babelBundleImpl.ts b/packages/playwright/bundles/babel/src/babelBundleImpl.ts index d58554b44b..a040deddb2 100644 --- a/packages/playwright/bundles/babel/src/babelBundleImpl.ts +++ b/packages/playwright/bundles/babel/src/babelBundleImpl.ts @@ -14,16 +14,18 @@ * limitations under the License. */ -import path from 'path'; -import type { BabelFileResult, NodePath, PluginObj, TransformOptions } from '@babel/core'; -import type { TSExportAssignment, ImportDeclaration } from '@babel/types'; -import type { TemplateBuilder } from '@babel/template'; +import * as path from 'path'; + import * as babel from '@babel/core'; +import traverseFunction from '@babel/traverse'; + +import type { BabelFileResult, NodePath, PluginObj, TransformOptions } from '@babel/core'; +import type { TemplateBuilder } from '@babel/template'; +import type { ImportDeclaration, TSExportAssignment } from '@babel/types'; export { codeFrameColumns } from '@babel/code-frame'; export { declare } from '@babel/helper-plugin-utils'; export { types } from '@babel/core'; -import traverseFunction from '@babel/traverse'; export const traverse = traverseFunction; function babelTransformOptions(isTypeScript: boolean, isModule: boolean, pluginsPrologue: [string, any?][], pluginsEpilogue: [string, any?][]): TransformOptions { diff --git a/packages/playwright/bundles/expect/src/expectBundleImpl.ts b/packages/playwright/bundles/expect/src/expectBundleImpl.ts index 875b48e614..0ffe8acbd8 100644 --- a/packages/playwright/bundles/expect/src/expectBundleImpl.ts +++ b/packages/playwright/bundles/expect/src/expectBundleImpl.ts @@ -14,11 +14,13 @@ * limitations under the License. */ +import * as mu from 'jest-matcher-utils'; + +import * as am from '../third_party/asymmetricMatchers'; import expectLibrary from '../third_party/index'; + export const expect = expectLibrary; export * as mock from 'jest-mock'; -import * as am from '../third_party/asymmetricMatchers'; -import * as mu from 'jest-matcher-utils'; export const asymmetricMatchers = { any: am.any, diff --git a/packages/playwright/bundles/expect/third_party/asymmetricMatchers.ts b/packages/playwright/bundles/expect/third_party/asymmetricMatchers.ts index 4e7a3402c9..a779f8be35 100644 --- a/packages/playwright/bundles/expect/third_party/asymmetricMatchers.ts +++ b/packages/playwright/bundles/expect/third_party/asymmetricMatchers.ts @@ -15,7 +15,9 @@ import { } from '@jest/expect-utils'; import * as matcherUtils from 'jest-matcher-utils'; import { pluralize } from 'jest-util'; + import { getCustomEqualityTesters, getState } from './jestMatchersObject'; + import type { AsymmetricMatcher as AsymmetricMatcherInterface, MatcherContext, diff --git a/packages/playwright/bundles/expect/third_party/extractExpectedAssertionsErrors.ts b/packages/playwright/bundles/expect/third_party/extractExpectedAssertionsErrors.ts index 1be9b4dce9..d50c01c692 100644 --- a/packages/playwright/bundles/expect/third_party/extractExpectedAssertionsErrors.ts +++ b/packages/playwright/bundles/expect/third_party/extractExpectedAssertionsErrors.ts @@ -12,7 +12,9 @@ import { matcherHint, pluralize, } from 'jest-matcher-utils'; + import { getState, setState } from './jestMatchersObject'; + import type { Expect, ExpectedAssertionsErrors } from './types'; const resetAssertionsLocalState = () => { diff --git a/packages/playwright/bundles/expect/third_party/index.ts b/packages/playwright/bundles/expect/third_party/index.ts index 3935ab71e1..7d5e7bce0e 100644 --- a/packages/playwright/bundles/expect/third_party/index.ts +++ b/packages/playwright/bundles/expect/third_party/index.ts @@ -9,6 +9,7 @@ import { equals, iterableEquality, subsetEquality } from '@jest/expect-utils'; import * as matcherUtils from 'jest-matcher-utils'; import { isPromise } from 'jest-util'; + import { any, anything, @@ -38,6 +39,7 @@ import spyMatchers from './spyMatchers'; import toThrowMatchers, { createMatcher as createThrowMatcher, } from './toThrowMatchers'; + import type { Expect, ExpectationResult, @@ -54,8 +56,8 @@ import type { export type { Tester, TesterContext } from '@jest/expect-utils'; export { AsymmetricMatcher } from './asymmetricMatchers'; export type { - AsyncExpectationResult, AsymmetricMatchers, + AsyncExpectationResult, BaseExpect, Expect, ExpectationResult, diff --git a/packages/playwright/bundles/expect/third_party/jestMatchersObject.ts b/packages/playwright/bundles/expect/third_party/jestMatchersObject.ts index 7a9a304b30..30879e11c1 100644 --- a/packages/playwright/bundles/expect/third_party/jestMatchersObject.ts +++ b/packages/playwright/bundles/expect/third_party/jestMatchersObject.ts @@ -6,15 +6,17 @@ * */ -import type { Tester } from '@jest/expect-utils'; import { getType } from 'jest-get-type'; + import { AsymmetricMatcher } from './asymmetricMatchers'; + import type { Expect, MatcherState, MatchersObject, SyncExpectationResult, } from './types'; +import type { Tester } from '@jest/expect-utils'; // Global matchers object holds the list of available matchers and // the state, that can hold matcher specific values that change over time. diff --git a/packages/playwright/bundles/expect/third_party/matchers.ts b/packages/playwright/bundles/expect/third_party/matchers.ts index 5102b50c32..fac0446666 100644 --- a/packages/playwright/bundles/expect/third_party/matchers.ts +++ b/packages/playwright/bundles/expect/third_party/matchers.ts @@ -23,7 +23,7 @@ import { getType, isPrimitive } from 'jest-get-type'; import { DIM_COLOR, EXPECTED_COLOR, - type MatcherHintOptions, + RECEIVED_COLOR, SUGGEST_TO_CONTAIN_EQUAL, ensureExpectedIsNonNegativeInteger, @@ -36,8 +36,9 @@ import { printExpected, printReceived, printWithType, - stringify, + stringify } from 'jest-matcher-utils'; + import { printCloseTo, printExpectedConstructorName, @@ -48,7 +49,9 @@ import { printReceivedStringContainExpectedResult, printReceivedStringContainExpectedSubstring, } from './print'; + import type { MatchersObject } from './types'; +import type { MatcherHintOptions } from 'jest-matcher-utils'; // Omit colon and one or more spaces, so can call getLabelPrinter. const EXPECTED_LABEL = 'Expected'; diff --git a/packages/playwright/bundles/expect/third_party/spyMatchers.ts b/packages/playwright/bundles/expect/third_party/spyMatchers.ts index ac74fd8d91..038351bc06 100644 --- a/packages/playwright/bundles/expect/third_party/spyMatchers.ts +++ b/packages/playwright/bundles/expect/third_party/spyMatchers.ts @@ -10,7 +10,7 @@ import { getType, isPrimitive } from 'jest-get-type'; import { DIM_COLOR, EXPECTED_COLOR, - type MatcherHintOptions, + RECEIVED_COLOR, diff, ensureExpectedIsNonNegativeInteger, @@ -20,14 +20,17 @@ import { printExpected, printReceived, printWithType, - stringify, + stringify } from 'jest-matcher-utils'; + import { getCustomEqualityTesters } from './jestMatchersObject'; + import type { MatcherFunction, MatchersObject, SyncExpectationResult, } from './types'; +import type { MatcherHintOptions } from 'jest-matcher-utils'; /* eslint-disable eqeqeq */ diff --git a/packages/playwright/bundles/expect/third_party/toThrowMatchers.ts b/packages/playwright/bundles/expect/third_party/toThrowMatchers.ts index 5a2bb9dcad..bcb8697379 100644 --- a/packages/playwright/bundles/expect/third_party/toThrowMatchers.ts +++ b/packages/playwright/bundles/expect/third_party/toThrowMatchers.ts @@ -9,16 +9,17 @@ import { isError } from '@jest/expect-utils'; import { EXPECTED_COLOR, - type MatcherHintOptions, + RECEIVED_COLOR, matcherErrorMessage, matcherHint, printDiffOrStringify, printExpected, printReceived, - printWithType, + printWithType } from 'jest-matcher-utils'; import { formatStackTrace, separateMessageFromStack } from 'jest-message-util'; + import { printExpectedConstructorName, printExpectedConstructorNameNot, @@ -27,12 +28,14 @@ import { printReceivedStringContainExpectedResult, printReceivedStringContainExpectedSubstring, } from './print'; + import type { ExpectationResult, MatcherFunction, MatchersObject, SyncExpectationResult, } from './types'; +import type { MatcherHintOptions } from 'jest-matcher-utils'; /* eslint-disable eqeqeq */ diff --git a/packages/playwright/bundles/expect/third_party/types.ts b/packages/playwright/bundles/expect/third_party/types.ts index abaa3a3b69..65660ff38b 100644 --- a/packages/playwright/bundles/expect/third_party/types.ts +++ b/packages/playwright/bundles/expect/third_party/types.ts @@ -6,9 +6,9 @@ * */ +import type { INTERNAL_MATCHER_FLAG } from './jestMatchersObject'; import type { EqualsFunction, Tester } from '@jest/expect-utils'; import type * as jestMatcherUtils from 'jest-matcher-utils'; -import type { INTERNAL_MATCHER_FLAG } from './jestMatchersObject'; export type SyncExpectationResult = { pass: boolean; diff --git a/packages/playwright/bundles/utils/src/utilsBundleImpl.ts b/packages/playwright/bundles/utils/src/utilsBundleImpl.ts index 6cd35e2885..6928295763 100644 --- a/packages/playwright/bundles/utils/src/utilsBundleImpl.ts +++ b/packages/playwright/bundles/utils/src/utilsBundleImpl.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +/* eslint-disable import/order */ + import json5Library from 'json5'; export const json5 = json5Library; diff --git a/packages/playwright/src/common/config.ts b/packages/playwright/src/common/config.ts index b55c3d6527..b0bc394873 100644 --- a/packages/playwright/src/common/config.ts +++ b/packages/playwright/src/common/config.ts @@ -14,15 +14,17 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import os from 'os'; -import type { Config, Fixtures, Project, ReporterDescription } from '../../types/test'; -import type { Location } from '../../types/testReporter'; -import type { TestRunnerPluginRegistration } from '../plugins'; +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; + import { getPackageJsonPath, mergeObjects } from '../util'; + +import type { Config, Fixtures, Project, ReporterDescription } from '../../types/test'; +import type { TestRunnerPluginRegistration } from '../plugins'; import type { Matcher } from '../util'; import type { ConfigCLIOverrides } from './ipc'; +import type { Location } from '../../types/testReporter'; import type { FullConfig, FullProject } from '../../types/testReporter'; export type ConfigLocation = { diff --git a/packages/playwright/src/common/configLoader.ts b/packages/playwright/src/common/configLoader.ts index b9f24b929a..da02b83c75 100644 --- a/packages/playwright/src/common/configLoader.ts +++ b/packages/playwright/src/common/configLoader.ts @@ -16,17 +16,20 @@ import * as fs from 'fs'; import * as path from 'path'; + import { gracefullyProcessExitDoNotHang, isRegExp } from 'playwright-core/lib/utils'; -import type { ConfigCLIOverrides, SerializedConfig } from './ipc'; + import { requireOrImport, setSingleTSConfig, setTransformConfig } from '../transform/transform'; -import type { Config, Project } from '../../types/test'; import { errorWithFile, fileIsModule } from '../util'; -import type { ConfigLocation } from './config'; import { FullConfigInternal } from './config'; -import { addToCompilationCache } from '../transform/compilationCache'; import { configureESMLoader, configureESMLoaderTransformConfig, registerESMLoader } from './esmLoaderHost'; +import { addToCompilationCache } from '../transform/compilationCache'; import { execArgvWithExperimentalLoaderOptions, execArgvWithoutExperimentalLoaderOptions } from '../transform/esmUtils'; +import type { ConfigLocation } from './config'; +import type { ConfigCLIOverrides, SerializedConfig } from './ipc'; +import type { Config, Project } from '../../types/test'; + const kDefineConfigWasUsed = Symbol('defineConfigWasUsed'); export const defineConfig = (...configs: any[]) => { let result = configs[0]; diff --git a/packages/playwright/src/common/esmLoaderHost.ts b/packages/playwright/src/common/esmLoaderHost.ts index 9daa71107c..fbe5704044 100644 --- a/packages/playwright/src/common/esmLoaderHost.ts +++ b/packages/playwright/src/common/esmLoaderHost.ts @@ -14,10 +14,11 @@ * limitations under the License. */ -import url from 'url'; +import * as url from 'url'; + import { addToCompilationCache, serializeCompilationCache } from '../transform/compilationCache'; -import { singleTSConfig, transformConfig } from '../transform/transform'; import { PortTransport } from '../transform/portTransport'; +import { singleTSConfig, transformConfig } from '../transform/transform'; let loaderChannel: PortTransport | undefined; // Node.js < 20 diff --git a/packages/playwright/src/common/fixtures.ts b/packages/playwright/src/common/fixtures.ts index 6b50947ab5..ad0a16bd22 100644 --- a/packages/playwright/src/common/fixtures.ts +++ b/packages/playwright/src/common/fixtures.ts @@ -14,11 +14,13 @@ * limitations under the License. */ -import { filterStackFile, formatLocation } from '../util'; import * as crypto from 'crypto'; + +import { filterStackFile, formatLocation } from '../util'; + +import type { FixturesWithLocation } from './config'; import type { Fixtures } from '../../types/test'; import type { Location } from '../../types/testReporter'; -import type { FixturesWithLocation } from './config'; export type FixtureScope = 'test' | 'worker'; type FixtureAuto = boolean | 'all-hooks-included'; diff --git a/packages/playwright/src/common/globals.ts b/packages/playwright/src/common/globals.ts index 746e1ec847..41f912acb8 100644 --- a/packages/playwright/src/common/globals.ts +++ b/packages/playwright/src/common/globals.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import type { TestInfoImpl } from '../worker/testInfo'; import type { Suite } from './test'; +import type { TestInfoImpl } from '../worker/testInfo'; let currentTestInfoValue: TestInfoImpl | null = null; export function setCurrentTestInfo(testInfo: TestInfoImpl | null) { diff --git a/packages/playwright/src/common/ipc.ts b/packages/playwright/src/common/ipc.ts index 2e085f5b78..d1cebd5cb4 100644 --- a/packages/playwright/src/common/ipc.ts +++ b/packages/playwright/src/common/ipc.ts @@ -15,11 +15,13 @@ */ import util from 'util'; + import { serializeCompilationCache } from '../transform/compilationCache'; -import type { SerializedCompilationCache } from '../transform/compilationCache'; + import type { ConfigLocation, FullConfigInternal } from './config'; import type { ReporterDescription, TestInfoError, TestStatus } from '../../types/test'; import type { MatcherResultProperty } from '../matchers/matcherHint'; +import type { SerializedCompilationCache } from '../transform/compilationCache'; export type ConfigCLIOverrides = { debug?: boolean; diff --git a/packages/playwright/src/common/poolBuilder.ts b/packages/playwright/src/common/poolBuilder.ts index cc1bc095c9..f975efe92f 100644 --- a/packages/playwright/src/common/poolBuilder.ts +++ b/packages/playwright/src/common/poolBuilder.ts @@ -15,11 +15,12 @@ */ import { FixturePool } from './fixtures'; +import { formatLocation } from '../util'; + +import type { FullProjectInternal } from './config'; import type { LoadError } from './fixtures'; import type { Suite, TestCase } from './test'; import type { TestTypeImpl } from './testType'; -import type { FullProjectInternal } from './config'; -import { formatLocation } from '../util'; import type { TestError } from '../../types/testReporter'; export class PoolBuilder { diff --git a/packages/playwright/src/common/process.ts b/packages/playwright/src/common/process.ts index a372139698..54dd2fe991 100644 --- a/packages/playwright/src/common/process.ts +++ b/packages/playwright/src/common/process.ts @@ -14,12 +14,14 @@ * limitations under the License. */ -import type { EnvProducedPayload, ProcessInitParams, TestInfoErrorImpl } from './ipc'; import { startProfiling, stopProfiling } from 'playwright-core/lib/utils'; + import { serializeError } from '../util'; import { registerESMLoader } from './esmLoaderHost'; import { execArgvWithoutExperimentalLoaderOptions } from '../transform/esmUtils'; +import type { EnvProducedPayload, ProcessInitParams, TestInfoErrorImpl } from './ipc'; + export type ProtocolRequest = { id: number; method: string; diff --git a/packages/playwright/src/common/suiteUtils.ts b/packages/playwright/src/common/suiteUtils.ts index 81dc9d5465..d229e62732 100644 --- a/packages/playwright/src/common/suiteUtils.ts +++ b/packages/playwright/src/common/suiteUtils.ts @@ -14,13 +14,16 @@ * limitations under the License. */ -import path from 'path'; +import * as path from 'path'; + import { calculateSha1, toPosixPath } from 'playwright-core/lib/utils'; -import type { Suite, TestCase } from './test'; -import type { FullProjectInternal } from './config'; -import type { Matcher, TestFileFilter } from '../util'; + import { createFileMatcher } from '../util'; +import type { FullProjectInternal } from './config'; +import type { Suite, TestCase } from './test'; +import type { Matcher, TestFileFilter } from '../util'; + export function filterSuite(suite: Suite, suiteFilter: (suites: Suite) => boolean, testFilter: (test: TestCase) => boolean) { for (const child of suite.suites) { diff --git a/packages/playwright/src/common/test.ts b/packages/playwright/src/common/test.ts index 3e7fb30a1a..7b54f0c291 100644 --- a/packages/playwright/src/common/test.ts +++ b/packages/playwright/src/common/test.ts @@ -14,14 +14,16 @@ * limitations under the License. */ -import type { FixturePool } from './fixtures'; -import type * as reporterTypes from '../../types/testReporter'; -import type { TestTypeImpl } from './testType'; import { rootTestType } from './testType'; -import type { Annotation, FixturesWithLocation, FullProjectInternal } from './config'; -import type { Location, FullProject } from '../../types/testReporter'; import { computeTestCaseOutcome } from '../isomorphic/teleReceiver'; +import type { Annotation, FixturesWithLocation, FullProjectInternal } from './config'; +import type { FixturePool } from './fixtures'; +import type { TestTypeImpl } from './testType'; +import type * as reporterTypes from '../../types/testReporter'; +import type { FullProject, Location } from '../../types/testReporter'; + + class Base { title: string; _only = false; diff --git a/packages/playwright/src/common/testLoader.ts b/packages/playwright/src/common/testLoader.ts index 6a8940ee19..31a7b63fee 100644 --- a/packages/playwright/src/common/testLoader.ts +++ b/packages/playwright/src/common/testLoader.ts @@ -14,15 +14,17 @@ * limitations under the License. */ -import path from 'path'; +import * as path from 'path'; import util from 'util'; -import type { TestError } from '../../types/testReporter'; + +import * as esmLoaderHost from './esmLoaderHost'; import { isWorkerProcess, setCurrentlyLoadingFileSuite } from './globals'; import { Suite } from './test'; +import { startCollectingFileDeps, stopCollectingFileDeps } from '../transform/compilationCache'; import { requireOrImport } from '../transform/transform'; import { filterStackTrace } from '../util'; -import { startCollectingFileDeps, stopCollectingFileDeps } from '../transform/compilationCache'; -import * as esmLoaderHost from './esmLoaderHost'; + +import type { TestError } from '../../types/testReporter'; export const defaultTimeout = 30000; diff --git a/packages/playwright/src/common/testType.ts b/packages/playwright/src/common/testType.ts index 71761b33e1..7395e38217 100644 --- a/packages/playwright/src/common/testType.ts +++ b/packages/playwright/src/common/testType.ts @@ -14,15 +14,18 @@ * limitations under the License. */ -import { expect } from '../matchers/expect'; -import { currentlyLoadingFileSuite, currentTestInfo, setCurrentlyLoadingFileSuite } from './globals'; -import { TestCase, Suite } from './test'; -import { wrapFunctionWithLocation } from '../transform/transform'; -import type { FixturesWithLocation } from './config'; -import type { Fixtures, TestType, TestDetails, TestStepInfo } from '../../types/test'; -import type { Location } from '../../types/testReporter'; -import { getPackageManagerExecCommand, monotonicTime, raceAgainstDeadline, zones } from 'playwright-core/lib/utils'; import { errors } from 'playwright-core'; +import { getPackageManagerExecCommand, monotonicTime, raceAgainstDeadline, zones } from 'playwright-core/lib/utils'; + +import { currentTestInfo, currentlyLoadingFileSuite, setCurrentlyLoadingFileSuite } from './globals'; +import { Suite, TestCase } from './test'; +import { expect } from '../matchers/expect'; +import { wrapFunctionWithLocation } from '../transform/transform'; + +import type { FixturesWithLocation } from './config'; +import type { Fixtures, TestDetails, TestStepInfo, TestType } from '../../types/test'; +import type { Location } from '../../types/testReporter'; + const testTypeSymbol = Symbol('testType'); diff --git a/packages/playwright/src/fsWatcher.ts b/packages/playwright/src/fsWatcher.ts index 53e6849b1a..4078e4f994 100644 --- a/packages/playwright/src/fsWatcher.ts +++ b/packages/playwright/src/fsWatcher.ts @@ -15,6 +15,7 @@ */ import { chokidar } from './utilsBundle'; + import type { FSWatcher } from 'chokidar'; export type FSEvent = { event: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', file: string }; diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.ts index 652e8ecab1..b2ba203386 100644 --- a/packages/playwright/src/index.ts +++ b/packages/playwright/src/index.ts @@ -16,16 +16,19 @@ import * as fs from 'fs'; import * as path from 'path'; -import type { APIRequestContext, BrowserContext, Browser, BrowserContextOptions, LaunchOptions, Page, Tracing, Video } from 'playwright-core'; + import * as playwrightLibrary from 'playwright-core'; -import { createGuid, debugMode, addInternalStackPrefix, isString, asLocator, jsonStringifyForceASCII, zones } from 'playwright-core/lib/utils'; -import type { Fixtures, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, ScreenshotMode, TestInfo, TestType, VideoMode } from '../types/test'; -import type { TestInfoImpl, TestStepInternal } from './worker/testInfo'; +import { addInternalStackPrefix, asLocator, createGuid, debugMode, isString, jsonStringifyForceASCII, zones } from 'playwright-core/lib/utils'; + +import { currentTestInfo } from './common/globals'; import { rootTestType } from './common/testType'; + +import type { Fixtures, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, ScreenshotMode, TestInfo, TestType, VideoMode } from '../types/test'; import type { ContextReuseMode } from './common/config'; +import type { TestInfoImpl, TestStepInternal } from './worker/testInfo'; import type { ApiCallData, ClientInstrumentation, ClientInstrumentationListener } from '../../playwright-core/src/client/clientInstrumentation'; import type { Playwright as PlaywrightImpl } from '../../playwright-core/src/client/playwright'; -import { currentTestInfo } from './common/globals'; +import type { APIRequestContext, Browser, BrowserContext, BrowserContextOptions, LaunchOptions, Page, Tracing, Video } from 'playwright-core'; export { expect } from './matchers/expect'; export const _baseTest: TestType<{}, {}> = rootTestType.test; diff --git a/packages/playwright/src/internalsForTest.ts b/packages/playwright/src/internalsForTest.ts index c0d2cbd95f..f80d63bc7a 100644 --- a/packages/playwright/src/internalsForTest.ts +++ b/packages/playwright/src/internalsForTest.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import path from 'path'; +import * as path from 'path'; + import { fileDependenciesForTest } from './transform/compilationCache'; export function fileDependencies() { diff --git a/packages/playwright/src/isomorphic/teleReceiver.ts b/packages/playwright/src/isomorphic/teleReceiver.ts index 1eb83df623..91b1a1a434 100644 --- a/packages/playwright/src/isomorphic/teleReceiver.ts +++ b/packages/playwright/src/isomorphic/teleReceiver.ts @@ -14,9 +14,9 @@ * limitations under the License. */ -import type { Annotation } from '../common/config'; import type { Metadata } from '../../types/test'; import type * as reporterTypes from '../../types/testReporter'; +import type { Annotation } from '../common/config'; import type { ReporterV2 } from '../reporters/reporterV2'; export type StringIntern = (s: string) => string; diff --git a/packages/playwright/src/isomorphic/teleSuiteUpdater.ts b/packages/playwright/src/isomorphic/teleSuiteUpdater.ts index 6f86c50147..7c4c14fae7 100644 --- a/packages/playwright/src/isomorphic/teleSuiteUpdater.ts +++ b/packages/playwright/src/isomorphic/teleSuiteUpdater.ts @@ -16,8 +16,9 @@ import { TeleReporterReceiver, TeleSuite } from './teleReceiver'; import { statusEx } from './testTree'; -import type { ReporterV2 } from '../reporters/reporterV2'; + import type * as reporterTypes from '../../types/testReporter'; +import type { ReporterV2 } from '../reporters/reporterV2'; export type TeleSuiteUpdaterProgress = { total: number; diff --git a/packages/playwright/src/isomorphic/testServerConnection.ts b/packages/playwright/src/isomorphic/testServerConnection.ts index 22bdce30ff..f4caf62fae 100644 --- a/packages/playwright/src/isomorphic/testServerConnection.ts +++ b/packages/playwright/src/isomorphic/testServerConnection.ts @@ -14,9 +14,10 @@ * limitations under the License. */ -import type { TestServerInterface, TestServerInterfaceEvents } from '@testIsomorphic/testServerInterface'; import * as events from './events'; +import type { TestServerInterface, TestServerInterfaceEvents } from '@testIsomorphic/testServerInterface'; + // -- Reuse boundary -- Everything below this line is reused in the vscode extension. export interface TestServerTransport { diff --git a/packages/playwright/src/isomorphic/testServerInterface.ts b/packages/playwright/src/isomorphic/testServerInterface.ts index e4faa682ac..470f44ee41 100644 --- a/packages/playwright/src/isomorphic/testServerInterface.ts +++ b/packages/playwright/src/isomorphic/testServerInterface.ts @@ -14,9 +14,9 @@ * limitations under the License. */ -import type * as reporterTypes from '../../types/testReporter'; import type { Event } from './events'; import type { JsonEvent } from './teleReceiver'; +import type * as reporterTypes from '../../types/testReporter'; // -- Reuse boundary -- Everything below this line is reused in the vscode extension. diff --git a/packages/playwright/src/loader/loaderMain.ts b/packages/playwright/src/loader/loaderMain.ts index 97befeea9d..50bd380c7c 100644 --- a/packages/playwright/src/loader/loaderMain.ts +++ b/packages/playwright/src/loader/loaderMain.ts @@ -14,15 +14,16 @@ * limitations under the License. */ -import type { SerializedConfig } from '../common/ipc'; import { deserializeConfig } from '../common/configLoader'; -import { ProcessRunner } from '../common/process'; -import type { FullConfigInternal } from '../common/config'; -import { loadTestFile } from '../common/testLoader'; -import type { TestError } from '../../types/testReporter'; -import { serializeCompilationCache } from '../transform/compilationCache'; -import { PoolBuilder } from '../common/poolBuilder'; import { incorporateCompilationCache } from '../common/esmLoaderHost'; +import { PoolBuilder } from '../common/poolBuilder'; +import { ProcessRunner } from '../common/process'; +import { loadTestFile } from '../common/testLoader'; +import { serializeCompilationCache } from '../transform/compilationCache'; + +import type { TestError } from '../../types/testReporter'; +import type { FullConfigInternal } from '../common/config'; +import type { SerializedConfig } from '../common/ipc'; export class LoaderMain extends ProcessRunner { private _serializedConfig: SerializedConfig; diff --git a/packages/playwright/src/matchers/expect.ts b/packages/playwright/src/matchers/expect.ts index 68e52c46c8..707e5457e1 100644 --- a/packages/playwright/src/matchers/expect.ts +++ b/packages/playwright/src/matchers/expect.ts @@ -19,6 +19,9 @@ import { createGuid, isString, pollAgainstDeadline } from 'playwright-core/lib/utils'; +import { zones } from 'playwright-core/lib/utils'; + +import { ExpectError, isJestError } from './matcherHint'; import { toBeAttached, toBeChecked, @@ -33,12 +36,12 @@ import { toBeVisible, toContainText, toHaveAccessibleDescription, - toHaveAccessibleName, toHaveAccessibleErrorMessage, + toHaveAccessibleName, toHaveAttribute, + toHaveCSS, toHaveClass, toHaveCount, - toHaveCSS, toHaveId, toHaveJSProperty, toHaveRole, @@ -49,22 +52,22 @@ import { toHaveValues, toPass } from './matchers'; -import type { ExpectMatcherStateInternal } from './matchers'; -import { toMatchSnapshot, toHaveScreenshot, toHaveScreenshotStepTitle } from './toMatchSnapshot'; -import type { Expect } from '../../types/test'; -import { currentTestInfo } from '../common/globals'; -import { filteredStackTrace, trimLongString } from '../util'; +import { toMatchAriaSnapshot } from './toMatchAriaSnapshot'; +import { toHaveScreenshot, toHaveScreenshotStepTitle, toMatchSnapshot } from './toMatchSnapshot'; import { - expect as expectLibrary, INVERTED_COLOR, RECEIVED_COLOR, + expect as expectLibrary, printReceived, } from '../common/expectBundle'; -import { zones } from 'playwright-core/lib/utils'; +import { currentTestInfo } from '../common/globals'; +import { filteredStackTrace, trimLongString } from '../util'; import { TestInfoImpl } from '../worker/testInfo'; + +import type { ExpectMatcherStateInternal } from './matchers'; +import type { Expect } from '../../types/test'; import type { TestStepInfoImpl } from '../worker/testInfo'; -import { ExpectError, isJestError } from './matcherHint'; -import { toMatchAriaSnapshot } from './toMatchAriaSnapshot'; + // #region // Mirrored from https://github.com/facebook/jest/blob/f13abff8df9a0e1148baf3584bcde6d1b479edc7/packages/expect/src/print.ts diff --git a/packages/playwright/src/matchers/matcherHint.ts b/packages/playwright/src/matchers/matcherHint.ts index dc4264d56b..1dfa1ceb4a 100644 --- a/packages/playwright/src/matchers/matcherHint.ts +++ b/packages/playwright/src/matchers/matcherHint.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -import { colors } from 'playwright-core/lib/utilsBundle'; -import type { ExpectMatcherState } from '../../types/test'; -import type { Locator } from 'playwright-core'; -import type { StackFrame } from '@protocol/channels'; import { stringifyStackFrames } from 'playwright-core/lib/utils'; +import { colors } from 'playwright-core/lib/utilsBundle'; + +import type { ExpectMatcherState } from '../../types/test'; +import type { StackFrame } from '@protocol/channels'; +import type { Locator } from 'playwright-core'; export const kNoElementsFoundError = ''; diff --git a/packages/playwright/src/matchers/matchers.ts b/packages/playwright/src/matchers/matchers.ts index be960dd424..2890feaac6 100644 --- a/packages/playwright/src/matchers/matchers.ts +++ b/packages/playwright/src/matchers/matchers.ts @@ -14,20 +14,22 @@ * limitations under the License. */ -import type { Locator, Page, APIResponse } from 'playwright-core'; -import type { FrameExpectParams } from 'playwright-core/lib/client/types'; +import { isRegExp, isString, isTextualMimeType, pollAgainstDeadline, serializeExpectedTextValues } from 'playwright-core/lib/utils'; import { colors } from 'playwright-core/lib/utilsBundle'; -import { expectTypes, callLogText } from '../util'; + +import { callLogText, expectTypes } from '../util'; import { toBeTruthy } from './toBeTruthy'; import { toEqual } from './toEqual'; +import { toHaveURL as toHaveURLExternal } from './toHaveURL'; import { toMatchText } from './toMatchText'; -import { isRegExp, isString, isTextualMimeType, pollAgainstDeadline, serializeExpectedTextValues } from 'playwright-core/lib/utils'; +import { takeFirst } from '../common/config'; import { currentTestInfo } from '../common/globals'; import { TestInfoImpl } from '../worker/testInfo'; -import type { TestStepInfoImpl } from '../worker/testInfo'; + import type { ExpectMatcherState } from '../../types/test'; -import { takeFirst } from '../common/config'; -import { toHaveURL as toHaveURLExternal } from './toHaveURL'; +import type { TestStepInfoImpl } from '../worker/testInfo'; +import type { APIResponse, Locator, Page } from 'playwright-core'; +import type { FrameExpectParams } from 'playwright-core/lib/client/types'; export type ExpectMatcherStateInternal = ExpectMatcherState & { _stepInfo?: TestStepInfoImpl }; diff --git a/packages/playwright/src/matchers/toBeTruthy.ts b/packages/playwright/src/matchers/toBeTruthy.ts index 0075dd5a64..0faf5555a9 100644 --- a/packages/playwright/src/matchers/toBeTruthy.ts +++ b/packages/playwright/src/matchers/toBeTruthy.ts @@ -14,8 +14,9 @@ * limitations under the License. */ -import { expectTypes, callLogText } from '../util'; +import { callLogText, expectTypes } from '../util'; import { kNoElementsFoundError, matcherHint } from './matcherHint'; + import type { MatcherResult } from './matcherHint'; import type { ExpectMatcherState } from '../../types/test'; import type { Locator } from 'playwright-core'; diff --git a/packages/playwright/src/matchers/toEqual.ts b/packages/playwright/src/matchers/toEqual.ts index 4296444a7b..ecbcb15239 100644 --- a/packages/playwright/src/matchers/toEqual.ts +++ b/packages/playwright/src/matchers/toEqual.ts @@ -14,12 +14,14 @@ * limitations under the License. */ -import { expectTypes, callLogText } from '../util'; +import { isRegExp } from 'playwright-core/lib/utils'; + +import { callLogText, expectTypes } from '../util'; import { matcherHint } from './matcherHint'; + import type { MatcherResult } from './matcherHint'; import type { ExpectMatcherState } from '../../types/test'; import type { Locator } from 'playwright-core'; -import { isRegExp } from 'playwright-core/lib/utils'; // Omit colon and one or more spaces, so can call getLabelPrinter. const EXPECTED_LABEL = 'Expected'; diff --git a/packages/playwright/src/matchers/toHaveURL.ts b/packages/playwright/src/matchers/toHaveURL.ts index df09833f84..c56441fee5 100644 --- a/packages/playwright/src/matchers/toHaveURL.ts +++ b/packages/playwright/src/matchers/toHaveURL.ts @@ -14,13 +14,16 @@ * limitations under the License. */ -import type { Page } from 'playwright-core'; -import type { ExpectMatcherState } from '../../types/test'; -import { EXPECTED_COLOR, printReceived } from '../common/expectBundle'; -import { matcherHint, type MatcherResult } from './matcherHint'; import { constructURLBasedOnBaseURL, urlMatches } from 'playwright-core/lib/utils'; import { colors } from 'playwright-core/lib/utilsBundle'; + import { printReceivedStringContainExpectedResult, printReceivedStringContainExpectedSubstring } from './expect'; +import { matcherHint } from './matcherHint'; +import { EXPECTED_COLOR, printReceived } from '../common/expectBundle'; + +import type { MatcherResult } from './matcherHint'; +import type { ExpectMatcherState } from '../../types/test'; +import type { Page } from 'playwright-core'; export async function toHaveURL( this: ExpectMatcherState, diff --git a/packages/playwright/src/matchers/toMatchAriaSnapshot.ts b/packages/playwright/src/matchers/toMatchAriaSnapshot.ts index 412a4bf275..1ad5777871 100644 --- a/packages/playwright/src/matchers/toMatchAriaSnapshot.ts +++ b/packages/playwright/src/matchers/toMatchAriaSnapshot.ts @@ -15,17 +15,22 @@ */ -import type { LocatorEx } from './matchers'; -import type { ExpectMatcherState } from '../../types/test'; -import { kNoElementsFoundError, matcherHint, type MatcherResult } from './matcherHint'; +import * as fs from 'fs'; +import * as path from 'path'; + +import { escapeTemplateString, isString, sanitizeForFilePath } from 'playwright-core/lib/utils'; + +import { kNoElementsFoundError, matcherHint } from './matcherHint'; import { EXPECTED_COLOR } from '../common/expectBundle'; import { callLogText, sanitizeFilePathBeforeExtension, trimLongString } from '../util'; import { printReceivedStringContainExpectedSubstring } from './expect'; import { currentTestInfo } from '../common/globals'; + +import type { MatcherResult } from './matcherHint'; +import type { LocatorEx } from './matchers'; +import type { ExpectMatcherState } from '../../types/test'; import type { MatcherReceived } from '@injected/ariaSnapshot'; -import { escapeTemplateString, isString, sanitizeForFilePath } from 'playwright-core/lib/utils'; -import fs from 'fs'; -import path from 'path'; + type ToMatchAriaSnapshotExpected = { name?: string; diff --git a/packages/playwright/src/matchers/toMatchSnapshot.ts b/packages/playwright/src/matchers/toMatchSnapshot.ts index 09ca66ab3c..220c948887 100644 --- a/packages/playwright/src/matchers/toMatchSnapshot.ts +++ b/packages/playwright/src/matchers/toMatchSnapshot.ts @@ -14,25 +14,29 @@ * limitations under the License. */ -import type { Locator, Page } from 'playwright-core'; -import type { ExpectScreenshotOptions, Page as PageEx } from 'playwright-core/lib/client/page'; -import { currentTestInfo } from '../common/globals'; -import type { ImageComparatorOptions, Comparator } from 'playwright-core/lib/utils'; +import * as fs from 'fs'; +import * as path from 'path'; + import { compareBuffersOrStrings, getComparator, isString, sanitizeForFilePath } from 'playwright-core/lib/utils'; +import { colors } from 'playwright-core/lib/utilsBundle'; +import { mime } from 'playwright-core/lib/utilsBundle'; + import { - addSuffixToFilePath, - trimLongString, callLogText, + addSuffixToFilePath, callLogText, expectTypes, sanitizeFilePathBeforeExtension, + trimLongString, windowsFilesystemFriendlyLength } from '../util'; -import { colors } from 'playwright-core/lib/utilsBundle'; -import fs from 'fs'; -import path from 'path'; -import { mime } from 'playwright-core/lib/utilsBundle'; -import type { TestInfoImpl, TestStepInfoImpl } from '../worker/testInfo'; +import { matcherHint } from './matcherHint'; +import { currentTestInfo } from '../common/globals'; + +import type { MatcherResult } from './matcherHint'; import type { ExpectMatcherStateInternal } from './matchers'; -import { matcherHint, type MatcherResult } from './matcherHint'; import type { FullProjectInternal } from '../common/config'; +import type { TestInfoImpl, TestStepInfoImpl } from '../worker/testInfo'; +import type { Locator, Page } from 'playwright-core'; +import type { ExpectScreenshotOptions, Page as PageEx } from 'playwright-core/lib/client/page'; +import type { Comparator, ImageComparatorOptions } from 'playwright-core/lib/utils'; type NameOrSegments = string | string[]; const snapshotNamesSymbol = Symbol('snapshotNames'); diff --git a/packages/playwright/src/matchers/toMatchText.ts b/packages/playwright/src/matchers/toMatchText.ts index 2f8bc34b21..961937eb5b 100644 --- a/packages/playwright/src/matchers/toMatchText.ts +++ b/packages/playwright/src/matchers/toMatchText.ts @@ -15,17 +15,19 @@ */ -import { expectTypes, callLogText } from '../util'; +import { colors } from 'playwright-core/lib/utilsBundle'; + +import { callLogText, expectTypes } from '../util'; import { printReceivedStringContainExpectedResult, printReceivedStringContainExpectedSubstring } from './expect'; -import { EXPECTED_COLOR } from '../common/expectBundle'; -import type { ExpectMatcherState } from '../../types/test'; import { kNoElementsFoundError, matcherHint } from './matcherHint'; +import { EXPECTED_COLOR } from '../common/expectBundle'; + import type { MatcherResult } from './matcherHint'; +import type { ExpectMatcherState } from '../../types/test'; import type { Locator } from 'playwright-core'; -import { colors } from 'playwright-core/lib/utilsBundle'; export async function toMatchText( this: ExpectMatcherState, diff --git a/packages/playwright/src/plugins/gitCommitInfoPlugin.ts b/packages/playwright/src/plugins/gitCommitInfoPlugin.ts index e96c122cc6..29010183c7 100644 --- a/packages/playwright/src/plugins/gitCommitInfoPlugin.ts +++ b/packages/playwright/src/plugins/gitCommitInfoPlugin.ts @@ -15,6 +15,7 @@ */ import { createGuid, spawnAsync } from 'playwright-core/lib/utils'; + import type { TestRunnerPlugin } from './'; import type { FullConfig } from '../../types/testReporter'; import type { FullConfigInternal } from '../common/config'; diff --git a/packages/playwright/src/plugins/webServerPlugin.ts b/packages/playwright/src/plugins/webServerPlugin.ts index 002ad235bd..5f30a58e95 100644 --- a/packages/playwright/src/plugins/webServerPlugin.ts +++ b/packages/playwright/src/plugins/webServerPlugin.ts @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import path from 'path'; -import net from 'net'; +import * as net from 'net'; +import * as path from 'path'; +import { isURLAvailable, launchProcess, monotonicTime, raceAgainstDeadline } from 'playwright-core/lib/utils'; import { colors, debug } from 'playwright-core/lib/utilsBundle'; -import { raceAgainstDeadline, launchProcess, monotonicTime, isURLAvailable } from 'playwright-core/lib/utils'; -import type { FullConfig } from '../../types/testReporter'; import type { TestRunnerPlugin } from '.'; +import type { FullConfig } from '../../types/testReporter'; import type { FullConfigInternal } from '../common/config'; import type { ReporterV2 } from '../reporters/reporterV2'; diff --git a/packages/playwright/src/program.ts b/packages/playwright/src/program.ts index c6278dc0ad..5100e06f37 100644 --- a/packages/playwright/src/program.ts +++ b/packages/playwright/src/program.ts @@ -16,25 +16,28 @@ /* eslint-disable no-console */ -import type { Command } from 'playwright-core/lib/utilsBundle'; -import fs from 'fs'; -import path from 'path'; -import { Runner } from './runner/runner'; -import { stopProfiling, startProfiling, gracefullyProcessExitDoNotHang } from 'playwright-core/lib/utils'; -import { serializeError } from './util'; +import * as fs from 'fs'; +import * as path from 'path'; + +import { program } from 'playwright-core/lib/cli/program'; +import { gracefullyProcessExitDoNotHang, startProfiling, stopProfiling } from 'playwright-core/lib/utils'; + +import { builtInReporters, defaultReporter, defaultTimeout } from './common/config'; +import { loadConfigFromFileRestartIfNeeded, loadEmptyConfigForMergeReports, resolveConfigLocation } from './common/configLoader'; +export { program } from 'playwright-core/lib/cli/program'; +import { prepareErrorStack } from './reporters/base'; import { showHTMLReport } from './reporters/html'; import { createMergedReport } from './reporters/merge'; -import { loadConfigFromFileRestartIfNeeded, loadEmptyConfigForMergeReports, resolveConfigLocation } from './common/configLoader'; -import type { ConfigCLIOverrides } from './common/ipc'; -import type { TestError } from '../types/testReporter'; -import type { TraceMode } from '../types/test'; -import { builtInReporters, defaultReporter, defaultTimeout } from './common/config'; -import { program } from 'playwright-core/lib/cli/program'; -export { program } from 'playwright-core/lib/cli/program'; -import type { ReporterDescription } from '../types/test'; -import { prepareErrorStack } from './reporters/base'; +import { Runner } from './runner/runner'; import * as testServer from './runner/testServer'; import { runWatchModeLoop } from './runner/watchMode'; +import { serializeError } from './util'; + +import type { TestError } from '../types/testReporter'; +import type { ConfigCLIOverrides } from './common/ipc'; +import type { TraceMode } from '../types/test'; +import type { ReporterDescription } from '../types/test'; +import type { Command } from 'playwright-core/lib/utilsBundle'; function addTestCommand(program: Command) { const command = program.command('test [test-filter...]'); diff --git a/packages/playwright/src/reporters/base.ts b/packages/playwright/src/reporters/base.ts index ec11413391..96f47fb192 100644 --- a/packages/playwright/src/reporters/base.ts +++ b/packages/playwright/src/reporters/base.ts @@ -14,13 +14,16 @@ * limitations under the License. */ -import { colors as realColors, ms as milliseconds, parseStackTraceLine } from 'playwright-core/lib/utilsBundle'; -import path from 'path'; -import type { FullConfig, TestCase, Suite, TestResult, TestError, FullResult, TestStep, Location } from '../../types/testReporter'; +import * as path from 'path'; + import { getPackageManagerExecCommand } from 'playwright-core/lib/utils'; -import { getEastAsianWidth } from '../utilsBundle'; -import type { ReporterV2 } from './reporterV2'; +import { colors as realColors, ms as milliseconds, parseStackTraceLine } from 'playwright-core/lib/utilsBundle'; + import { resolveReporterOutputPath } from '../util'; +import { getEastAsianWidth } from '../utilsBundle'; + +import type { ReporterV2 } from './reporterV2'; +import type { FullConfig, FullResult, Location, Suite, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter'; export type TestResultOutput = { chunk: string | Buffer, type: 'stdout' | 'stderr' }; export const kOutputSymbol = Symbol('output'); diff --git a/packages/playwright/src/reporters/blob.ts b/packages/playwright/src/reporters/blob.ts index 837fe55be0..4f913ba452 100644 --- a/packages/playwright/src/reporters/blob.ts +++ b/packages/playwright/src/reporters/blob.ts @@ -14,17 +14,20 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; +import { Readable } from 'stream'; + import { ManualPromise, calculateSha1, createGuid, getUserAgent, removeFolders, sanitizeForFilePath } from 'playwright-core/lib/utils'; import { mime } from 'playwright-core/lib/utilsBundle'; -import { Readable } from 'stream'; -import type { EventEmitter } from 'events'; +import { yazl } from 'playwright-core/lib/zipBundle'; + +import { resolveOutputFile } from './base'; +import { TeleReporterEmitter } from './teleEmitter'; + import type { FullConfig, FullResult, TestResult } from '../../types/testReporter'; import type { JsonAttachment, JsonEvent } from '../isomorphic/teleReceiver'; -import { TeleReporterEmitter } from './teleEmitter'; -import { yazl } from 'playwright-core/lib/zipBundle'; -import { resolveOutputFile } from './base'; +import type { EventEmitter } from 'events'; type BlobReporterOptions = { configDir: string; diff --git a/packages/playwright/src/reporters/dot.ts b/packages/playwright/src/reporters/dot.ts index 7f635f8214..b3e7b114c0 100644 --- a/packages/playwright/src/reporters/dot.ts +++ b/packages/playwright/src/reporters/dot.ts @@ -15,7 +15,8 @@ */ import { TerminalReporter } from './base'; -import type { FullResult, TestCase, TestResult, Suite, TestError } from '../../types/testReporter'; + +import type { FullResult, Suite, TestCase, TestError, TestResult } from '../../types/testReporter'; class DotReporter extends TerminalReporter { private _counter = 0; diff --git a/packages/playwright/src/reporters/github.ts b/packages/playwright/src/reporters/github.ts index e7ec7198fb..e3677dd3ff 100644 --- a/packages/playwright/src/reporters/github.ts +++ b/packages/playwright/src/reporters/github.ts @@ -14,10 +14,13 @@ * limitations under the License. */ +import * as path from 'path'; + import { ms as milliseconds } from 'playwright-core/lib/utilsBundle'; -import path from 'path'; + import { TerminalReporter, formatResultFailure, formatRetry, noColors, stripAnsiEscapes } from './base'; -import type { TestCase, FullResult, TestError } from '../../types/testReporter'; + +import type { FullResult, TestCase, TestError } from '../../types/testReporter'; type GitHubLogType = 'debug' | 'notice' | 'warning' | 'error'; diff --git a/packages/playwright/src/reporters/html.ts b/packages/playwright/src/reporters/html.ts index e258f22798..557ad580b7 100644 --- a/packages/playwright/src/reporters/html.ts +++ b/packages/playwright/src/reporters/html.ts @@ -14,23 +14,26 @@ * limitations under the License. */ -import { colors, open } from 'playwright-core/lib/utilsBundle'; -import { MultiMap, getPackageManagerExecCommand } from 'playwright-core/lib/utils'; -import fs from 'fs'; -import path from 'path'; -import type { TransformCallback } from 'stream'; +import * as fs from 'fs'; +import * as path from 'path'; import { Transform } from 'stream'; -import { codeFrameColumns } from '../transform/babelBundle'; -import type * as api from '../../types/testReporter'; + +import { MultiMap, getPackageManagerExecCommand } from 'playwright-core/lib/utils'; import { HttpServer, assert, calculateSha1, copyFileAndMakeWritable, gracefullyProcessExitDoNotHang, removeFolders, sanitizeForFilePath, toPosixPath } from 'playwright-core/lib/utils'; -import { formatError, formatResultFailure, internalScreen, stripAnsiEscapes } from './base'; -import { resolveReporterOutputPath } from '../util'; -import type { Metadata } from '../../types/test'; -import type { ZipFile } from 'playwright-core/lib/zipBundle'; -import { yazl } from 'playwright-core/lib/zipBundle'; +import { colors, open } from 'playwright-core/lib/utilsBundle'; import { mime } from 'playwright-core/lib/utilsBundle'; -import type { HTMLReport, Stats, TestAttachment, TestCase, TestCaseSummary, TestFile, TestFileSummary, TestResult, TestStep } from '@html-reporter/types'; +import { yazl } from 'playwright-core/lib/zipBundle'; + +import { formatError, formatResultFailure, internalScreen, stripAnsiEscapes } from './base'; +import { codeFrameColumns } from '../transform/babelBundle'; +import { resolveReporterOutputPath } from '../util'; + import type { ReporterV2 } from './reporterV2'; +import type { Metadata } from '../../types/test'; +import type * as api from '../../types/testReporter'; +import type { HTMLReport, Stats, TestAttachment, TestCase, TestCaseSummary, TestFile, TestFileSummary, TestResult, TestStep } from '@html-reporter/types'; +import type { ZipFile } from 'playwright-core/lib/zipBundle'; +import type { TransformCallback } from 'stream'; type TestEntry = { testCase: TestCase; diff --git a/packages/playwright/src/reporters/internalReporter.ts b/packages/playwright/src/reporters/internalReporter.ts index da5e667ffd..5655bd4fb2 100644 --- a/packages/playwright/src/reporters/internalReporter.ts +++ b/packages/playwright/src/reporters/internalReporter.ts @@ -14,14 +14,18 @@ * limitations under the License. */ -import fs from 'fs'; -import { codeFrameColumns } from '../transform/babelBundle'; -import type { FullConfig, TestCase, TestError, TestResult, FullResult, TestStep } from '../../types/testReporter'; -import { Suite } from '../common/test'; -import { internalScreen, prepareErrorStack, relativeFilePath } from './base'; -import type { ReporterV2 } from './reporterV2'; +import * as fs from 'fs'; + import { monotonicTime } from 'playwright-core/lib/utils'; + +import { internalScreen, prepareErrorStack, relativeFilePath } from './base'; import { Multiplexer } from './multiplexer'; +import { Suite } from '../common/test'; +import { codeFrameColumns } from '../transform/babelBundle'; + +import type { ReporterV2 } from './reporterV2'; +import type { FullConfig, FullResult, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter'; + export class InternalReporter implements ReporterV2 { private _reporter: ReporterV2; diff --git a/packages/playwright/src/reporters/json.ts b/packages/playwright/src/reporters/json.ts index 3c827aea78..377f4f3b88 100644 --- a/packages/playwright/src/reporters/json.ts +++ b/packages/playwright/src/reporters/json.ts @@ -14,13 +14,16 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import type { FullConfig, TestCase, Suite, TestResult, TestError, TestStep, FullResult, Location, JSONReport, JSONReportSuite, JSONReportSpec, JSONReportTest, JSONReportTestResult, JSONReportTestStep, JSONReportError } from '../../types/testReporter'; -import { formatError, nonTerminalScreen, prepareErrorStack, resolveOutputFile } from './base'; +import * as fs from 'fs'; +import * as path from 'path'; + import { MultiMap, toPosixPath } from 'playwright-core/lib/utils'; + +import { formatError, nonTerminalScreen, prepareErrorStack, resolveOutputFile } from './base'; import { getProjectId } from '../common/config'; + import type { ReporterV2 } from './reporterV2'; +import type { FullConfig, FullResult, JSONReport, JSONReportError, JSONReportSpec, JSONReportSuite, JSONReportTest, JSONReportTestResult, JSONReportTestStep, Location, Suite, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter'; type JSONOptions = { outputFile?: string, diff --git a/packages/playwright/src/reporters/junit.ts b/packages/playwright/src/reporters/junit.ts index 9140fb19d8..54aa1c519b 100644 --- a/packages/playwright/src/reporters/junit.ts +++ b/packages/playwright/src/reporters/junit.ts @@ -14,12 +14,15 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import type { FullConfig, FullResult, Suite, TestCase } from '../../types/testReporter'; -import { formatFailure, nonTerminalScreen, resolveOutputFile, stripAnsiEscapes } from './base'; +import * as fs from 'fs'; +import * as path from 'path'; + import { getAsBooleanFromENV } from 'playwright-core/lib/utils'; + +import { formatFailure, nonTerminalScreen, resolveOutputFile, stripAnsiEscapes } from './base'; + import type { ReporterV2 } from './reporterV2'; +import type { FullConfig, FullResult, Suite, TestCase } from '../../types/testReporter'; type JUnitOptions = { outputFile?: string, diff --git a/packages/playwright/src/reporters/line.ts b/packages/playwright/src/reporters/line.ts index 4ff5221224..b0bf0fd6fd 100644 --- a/packages/playwright/src/reporters/line.ts +++ b/packages/playwright/src/reporters/line.ts @@ -15,7 +15,8 @@ */ import { TerminalReporter } from './base'; -import type { TestCase, Suite, TestResult, FullResult, TestStep, TestError } from '../../types/testReporter'; + +import type { FullResult, Suite, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter'; class LineReporter extends TerminalReporter { private _current = 0; diff --git a/packages/playwright/src/reporters/list.ts b/packages/playwright/src/reporters/list.ts index aef9fcbe2f..e320a13cc4 100644 --- a/packages/playwright/src/reporters/list.ts +++ b/packages/playwright/src/reporters/list.ts @@ -14,10 +14,12 @@ * limitations under the License. */ -import { ms as milliseconds } from 'playwright-core/lib/utilsBundle'; -import { TerminalReporter, stepSuffix, stripAnsiEscapes } from './base'; -import type { FullResult, Suite, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter'; import { getAsBooleanFromENV } from 'playwright-core/lib/utils'; +import { ms as milliseconds } from 'playwright-core/lib/utilsBundle'; + +import { TerminalReporter, stepSuffix, stripAnsiEscapes } from './base'; + +import type { FullResult, Suite, TestCase, TestError, 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/src/reporters/markdown.ts b/packages/playwright/src/reporters/markdown.ts index 2b6bcbf063..158751f1b6 100644 --- a/packages/playwright/src/reporters/markdown.ts +++ b/packages/playwright/src/reporters/markdown.ts @@ -14,12 +14,14 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import type { FullResult, TestCase } from '../../types/testReporter'; +import * as fs from 'fs'; +import * as path from 'path'; + import { resolveReporterOutputPath } from '../util'; import { TerminalReporter } from './base'; +import type { FullResult, TestCase } from '../../types/testReporter'; + type MarkdownReporterOptions = { configDir: string, outputFile?: string; diff --git a/packages/playwright/src/reporters/merge.ts b/packages/playwright/src/reporters/merge.ts index 102335cceb..fcbecf865e 100644 --- a/packages/playwright/src/reporters/merge.ts +++ b/packages/playwright/src/reporters/merge.ts @@ -14,19 +14,23 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import type { ReporterDescription } from '../../types/test'; -import type { FullConfigInternal } from '../common/config'; -import type { JsonConfig, JsonEvent, JsonFullResult, JsonLocation, JsonProject, JsonSuite, JsonTestCase, JsonTestResultEnd, JsonTestStepStart, JsonTestStepEnd } from '../isomorphic/teleReceiver'; -import { TeleReporterReceiver } from '../isomorphic/teleReceiver'; -import { JsonStringInternalizer, StringInternPool } from '../isomorphic/stringInternPool'; -import { createReporters } from '../runner/reporters'; -import { Multiplexer } from './multiplexer'; +import * as fs from 'fs'; +import * as path from 'path'; + import { ZipFile } from 'playwright-core/lib/utils'; -import { currentBlobReportVersion, type BlobReportMetadata } from './blob'; + +import { currentBlobReportVersion } from './blob'; +import { Multiplexer } from './multiplexer'; +import { JsonStringInternalizer, StringInternPool } from '../isomorphic/stringInternPool'; +import { TeleReporterReceiver } from '../isomorphic/teleReceiver'; +import { createReporters } from '../runner/reporters'; import { relativeFilePath } from '../util'; + +import type { BlobReportMetadata } from './blob'; +import type { ReporterDescription } from '../../types/test'; import type { TestError } from '../../types/testReporter'; +import type { FullConfigInternal } from '../common/config'; +import type { JsonConfig, JsonEvent, JsonFullResult, JsonLocation, JsonProject, JsonSuite, JsonTestCase, JsonTestResultEnd, JsonTestStepEnd, JsonTestStepStart } from '../isomorphic/teleReceiver'; import type * as blobV1 from './versions/blobV1'; type StatusCallback = (message: string) => void; diff --git a/packages/playwright/src/reporters/multiplexer.ts b/packages/playwright/src/reporters/multiplexer.ts index b666128ab4..9ecc9de0f3 100644 --- a/packages/playwright/src/reporters/multiplexer.ts +++ b/packages/playwright/src/reporters/multiplexer.ts @@ -14,9 +14,9 @@ * limitations under the License. */ -import type { FullConfig, TestCase, TestError, TestResult, FullResult, TestStep } from '../../types/testReporter'; -import type { Suite } from '../common/test'; import type { ReporterV2 } from './reporterV2'; +import type { FullConfig, FullResult, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter'; +import type { Suite } from '../common/test'; export class Multiplexer implements ReporterV2 { private _reporters: ReporterV2[]; diff --git a/packages/playwright/src/reporters/reporterV2.ts b/packages/playwright/src/reporters/reporterV2.ts index 2cdffdfe12..94cee34213 100644 --- a/packages/playwright/src/reporters/reporterV2.ts +++ b/packages/playwright/src/reporters/reporterV2.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import type { FullConfig, TestCase, TestError, TestResult, FullResult, TestStep, Reporter, Suite } from '../../types/testReporter'; +import type { FullConfig, FullResult, Reporter, Suite, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter'; export interface ReporterV2 { onConfigure?(config: FullConfig): void; diff --git a/packages/playwright/src/reporters/teleEmitter.ts b/packages/playwright/src/reporters/teleEmitter.ts index 76fc1490a6..11d10987f2 100644 --- a/packages/playwright/src/reporters/teleEmitter.ts +++ b/packages/playwright/src/reporters/teleEmitter.ts @@ -14,12 +14,15 @@ * limitations under the License. */ -import path from 'path'; +import * as path from 'path'; + import { createGuid } from 'playwright-core/lib/utils'; + +import { serializeRegexPatterns } from '../isomorphic/teleReceiver'; + +import type { ReporterV2 } from './reporterV2'; import type * as reporterTypes from '../../types/testReporter'; import type * as teleReceiver from '../isomorphic/teleReceiver'; -import { serializeRegexPatterns } from '../isomorphic/teleReceiver'; -import type { ReporterV2 } from './reporterV2'; export type TeleReporterEmitterOptions = { omitOutput?: boolean; diff --git a/packages/playwright/src/runner/dispatcher.ts b/packages/playwright/src/runner/dispatcher.ts index 9f6367c106..084deba11d 100644 --- a/packages/playwright/src/runner/dispatcher.ts +++ b/packages/playwright/src/runner/dispatcher.ts @@ -14,20 +14,24 @@ * limitations under the License. */ -import type { TestBeginPayload, TestEndPayload, DonePayload, TestOutputPayload, StepBeginPayload, StepEndPayload, TeardownErrorsPayload, RunPayload, SerializedConfig, AttachmentPayload } from '../common/ipc'; -import { serializeConfig } from '../common/ipc'; -import type { TestResult, TestStep, TestError } from '../../types/testReporter'; -import type { Suite } from '../common/test'; -import type { ProcessExitData } from './processHost'; -import type { TestCase } from '../common/test'; -import { ManualPromise, type RegisteredListener, eventsHelper } from 'playwright-core/lib/utils'; -import { WorkerHost } from './workerHost'; -import type { TestGroup } from './testGroups'; -import type { FullConfigInternal } from '../common/config'; -import type { ReporterV2 } from '../reporters/reporterV2'; -import type { FailureTracker } from './failureTracker'; +import { ManualPromise, eventsHelper } from 'playwright-core/lib/utils'; import { colors } from 'playwright-core/lib/utilsBundle'; + import { addSuggestedRebaseline } from './rebase'; +import { WorkerHost } from './workerHost'; +import { serializeConfig } from '../common/ipc'; + +import type { FailureTracker } from './failureTracker'; +import type { ProcessExitData } from './processHost'; +import type { TestGroup } from './testGroups'; +import type { TestError, TestResult, TestStep } from '../../types/testReporter'; +import type { FullConfigInternal } from '../common/config'; +import type { AttachmentPayload, DonePayload, RunPayload, SerializedConfig, StepBeginPayload, StepEndPayload, TeardownErrorsPayload, TestBeginPayload, TestEndPayload, TestOutputPayload } from '../common/ipc'; +import type { Suite } from '../common/test'; +import type { TestCase } from '../common/test'; +import type { ReporterV2 } from '../reporters/reporterV2'; +import type { RegisteredListener } from 'playwright-core/lib/utils'; + export type EnvByProjectId = Map>; diff --git a/packages/playwright/src/runner/lastRun.ts b/packages/playwright/src/runner/lastRun.ts index 2152f977cf..158450ed41 100644 --- a/packages/playwright/src/runner/lastRun.ts +++ b/packages/playwright/src/runner/lastRun.ts @@ -14,10 +14,12 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import type { FullResult, Suite } from '../../types/testReporter'; +import * as fs from 'fs'; +import * as path from 'path'; + import { filterProjects } from './projectUtils'; + +import type { FullResult, Suite } from '../../types/testReporter'; import type { FullConfigInternal } from '../common/config'; import type { ReporterV2 } from '../reporters/reporterV2'; diff --git a/packages/playwright/src/runner/loadUtils.ts b/packages/playwright/src/runner/loadUtils.ts index 62799747b6..457444b94c 100644 --- a/packages/playwright/src/runner/loadUtils.ts +++ b/packages/playwright/src/runner/loadUtils.ts @@ -14,22 +14,25 @@ * limitations under the License. */ -import path from 'path'; -import type { FullConfig, Reporter, TestError } from '../../types/testReporter'; +import * as path from 'path'; + import { InProcessLoaderHost, OutOfProcessLoaderHost } from './loaderHost'; +import { createFileFiltersFromArguments, createFileMatcherFromArguments, createTitleMatcher, errorWithFile, forceRegExp } from '../util'; +import { buildProjectsClosure, collectFilesForProject, filterProjects } from './projectUtils'; +import { createTestGroups, filterForShard } from './testGroups'; +import { applyRepeatEachIndex, bindFileSuiteToProject, filterByFocusedLine, filterByTestIds, filterOnly, filterTestsRemoveEmptySuites } from '../common/suiteUtils'; import { Suite } from '../common/test'; -import type { TestCase } from '../common/test'; +import { dependenciesForTestFile } from '../transform/compilationCache'; +import { requireOrImport } from '../transform/transform'; +import { sourceMapSupport } from '../utilsBundle'; + +import type { TestRun } from './tasks'; +import type { TestGroup } from './testGroups'; +import type { FullConfig, Reporter, TestError } from '../../types/testReporter'; import type { FullProjectInternal } from '../common/config'; import type { FullConfigInternal } from '../common/config'; -import { createFileMatcherFromArguments, createFileFiltersFromArguments, createTitleMatcher, errorWithFile, forceRegExp } from '../util'; +import type { TestCase } from '../common/test'; import type { Matcher, TestFileFilter } from '../util'; -import { buildProjectsClosure, collectFilesForProject, filterProjects } from './projectUtils'; -import type { TestRun } from './tasks'; -import { requireOrImport } from '../transform/transform'; -import { applyRepeatEachIndex, bindFileSuiteToProject, filterByFocusedLine, filterByTestIds, filterOnly, filterTestsRemoveEmptySuites } from '../common/suiteUtils'; -import { createTestGroups, filterForShard, type TestGroup } from './testGroups'; -import { dependenciesForTestFile } from '../transform/compilationCache'; -import { sourceMapSupport } from '../utilsBundle'; import type { RawSourceMap } from '../utilsBundle'; diff --git a/packages/playwright/src/runner/loaderHost.ts b/packages/playwright/src/runner/loaderHost.ts index e6db22695b..369cf49a21 100644 --- a/packages/playwright/src/runner/loaderHost.ts +++ b/packages/playwright/src/runner/loaderHost.ts @@ -14,15 +14,17 @@ * limitations under the License. */ -import type { TestError } from '../../types/testReporter'; -import { serializeConfig } from '../common/ipc'; import { ProcessHost } from './processHost'; +import { incorporateCompilationCache } from '../common/esmLoaderHost'; +import { serializeConfig } from '../common/ipc'; +import { PoolBuilder } from '../common/poolBuilder'; import { Suite } from '../common/test'; import { loadTestFile } from '../common/testLoader'; -import type { FullConfigInternal } from '../common/config'; -import { PoolBuilder } from '../common/poolBuilder'; import { addToCompilationCache } from '../transform/compilationCache'; -import { incorporateCompilationCache } from '../common/esmLoaderHost'; + +import type { TestError } from '../../types/testReporter'; +import type { FullConfigInternal } from '../common/config'; + export class InProcessLoaderHost { private _config: FullConfigInternal; diff --git a/packages/playwright/src/runner/processHost.ts b/packages/playwright/src/runner/processHost.ts index 4c77c17857..cc972b2601 100644 --- a/packages/playwright/src/runner/processHost.ts +++ b/packages/playwright/src/runner/processHost.ts @@ -16,12 +16,15 @@ import child_process from 'child_process'; import { EventEmitter } from 'events'; + +import { assert } from 'playwright-core/lib/utils'; import { debug } from 'playwright-core/lib/utilsBundle'; + +import { esmLoaderRegistered } from '../common/esmLoaderHost'; +import { execArgvWithExperimentalLoaderOptions } from '../transform/esmUtils'; + import type { EnvProducedPayload, ProcessInitParams } from '../common/ipc'; import type { ProtocolResponse } from '../common/process'; -import { execArgvWithExperimentalLoaderOptions } from '../transform/esmUtils'; -import { assert } from 'playwright-core/lib/utils'; -import { esmLoaderRegistered } from '../common/esmLoaderHost'; export type ProcessExitData = { unexpectedly: boolean; diff --git a/packages/playwright/src/runner/projectUtils.ts b/packages/playwright/src/runner/projectUtils.ts index 49a6c89d84..7bb1495ba3 100644 --- a/packages/playwright/src/runner/projectUtils.ts +++ b/packages/playwright/src/runner/projectUtils.ts @@ -14,14 +14,18 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; +import { promisify } from 'util'; + import { escapeRegExp } from 'playwright-core/lib/utils'; import { minimatch } from 'playwright-core/lib/utilsBundle'; -import { promisify } from 'util'; -import type { FullProjectInternal } from '../common/config'; + import { createFileMatcher } from '../util'; +import type { FullProjectInternal } from '../common/config'; + + const readFileAsync = promisify(fs.readFile); const readDirAsync = promisify(fs.readdir); diff --git a/packages/playwright/src/runner/rebase.ts b/packages/playwright/src/runner/rebase.ts index b040761df9..c2d9f96d18 100644 --- a/packages/playwright/src/runner/rebase.ts +++ b/packages/playwright/src/runner/rebase.ts @@ -14,15 +14,19 @@ * limitations under the License. */ -import path from 'path'; -import fs from 'fs'; -import type { T } from '../transform/babelBundle'; -import { types, traverse, babelParse } from '../transform/babelBundle'; +import * as fs from 'fs'; +import * as path from 'path'; + + import { MultiMap } from 'playwright-core/lib/utils'; import { colors, diff } from 'playwright-core/lib/utilsBundle'; -import type { FullConfigInternal } from '../common/config'; + import { filterProjects } from './projectUtils'; +import { babelParse, traverse, types } from '../transform/babelBundle'; + +import type { FullConfigInternal } from '../common/config'; import type { InternalReporter } from '../reporters/internalReporter'; +import type { T } from '../transform/babelBundle'; const t: typeof T = types; type Location = { diff --git a/packages/playwright/src/runner/reporters.ts b/packages/playwright/src/runner/reporters.ts index b25cb84154..163b8b8e3e 100644 --- a/packages/playwright/src/runner/reporters.ts +++ b/packages/playwright/src/runner/reporters.ts @@ -14,10 +14,13 @@ * limitations under the License. */ -import path from 'path'; -import type { FullConfig, TestError } from '../../types/testReporter'; +import * as path from 'path'; + +import { calculateSha1 } from 'playwright-core/lib/utils'; + +import { loadReporter } from './loadUtils'; import { formatError, terminalScreen } from '../reporters/base'; -import type { Screen } from '../reporters/base'; +import { BlobReporter } from '../reporters/blob'; import DotReporter from '../reporters/dot'; import EmptyReporter from '../reporters/empty'; import GitHubReporter from '../reporters/github'; @@ -26,13 +29,15 @@ import JSONReporter from '../reporters/json'; import JUnitReporter from '../reporters/junit'; import LineReporter from '../reporters/line'; import ListReporter from '../reporters/list'; -import type { Suite } from '../common/test'; -import type { BuiltInReporter, FullConfigInternal } from '../common/config'; -import { loadReporter } from './loadUtils'; -import { BlobReporter } from '../reporters/blob'; +import { wrapReporterAsV2 } from '../reporters/reporterV2'; + import type { ReporterDescription } from '../../types/test'; -import { type ReporterV2, wrapReporterAsV2 } from '../reporters/reporterV2'; -import { calculateSha1 } from 'playwright-core/lib/utils'; +import type { FullConfig, TestError } from '../../types/testReporter'; +import type { BuiltInReporter, FullConfigInternal } from '../common/config'; +import type { Suite } from '../common/test'; +import type { Screen } from '../reporters/base'; +import type { ReporterV2 } from '../reporters/reporterV2'; + export async function createReporters(config: FullConfigInternal, mode: 'list' | 'test' | 'merge', isTestServer: boolean, descriptions?: ReporterDescription[]): Promise { const defaultReporters: { [key in BuiltInReporter]: new(arg: any) => ReporterV2 } = { diff --git a/packages/playwright/src/runner/runner.ts b/packages/playwright/src/runner/runner.ts index 51eb15e299..22694c251e 100644 --- a/packages/playwright/src/runner/runner.ts +++ b/packages/playwright/src/runner/runner.ts @@ -15,17 +15,19 @@ * limitations under the License. */ -import type { FullResult, TestError } from '../../types/testReporter'; -import { webServerPluginsForConfig } from '../plugins/webServerPlugin'; -import { addGitCommitInfoPlugin } from '../plugins/gitCommitInfoPlugin'; +import { LastRunReporter } from './lastRun'; import { collectFilesForProject, filterProjects } from './projectUtils'; import { createErrorCollectingReporter, createReporters } from './reporters'; import { TestRun, createApplyRebaselinesTask, createClearCacheTask, createGlobalSetupTasks, createLoadTask, createPluginSetupTasks, createReportBeginTask, createRunTestsTasks, createStartDevServerTask, runTasks } from './tasks'; -import type { FullConfigInternal } from '../common/config'; -import { affectedTestFiles } from '../transform/compilationCache'; -import { InternalReporter } from '../reporters/internalReporter'; -import { LastRunReporter } from './lastRun'; +import { addGitCommitInfoPlugin } from '../plugins/gitCommitInfoPlugin'; +import { webServerPluginsForConfig } from '../plugins/webServerPlugin'; import { terminalScreen } from '../reporters/base'; +import { InternalReporter } from '../reporters/internalReporter'; +import { affectedTestFiles } from '../transform/compilationCache'; + +import type { FullResult, TestError } from '../../types/testReporter'; +import type { FullConfigInternal } from '../common/config'; + type ProjectConfigWithFiles = { name: string; diff --git a/packages/playwright/src/runner/taskRunner.ts b/packages/playwright/src/runner/taskRunner.ts index dd29d6b0f8..12185aa951 100644 --- a/packages/playwright/src/runner/taskRunner.ts +++ b/packages/playwright/src/runner/taskRunner.ts @@ -14,11 +14,14 @@ * limitations under the License. */ -import { colors, debug } from 'playwright-core/lib/utilsBundle'; import { ManualPromise, monotonicTime } from 'playwright-core/lib/utils'; -import type { FullResult, TestError } from '../../types/testReporter'; +import { colors, debug } from 'playwright-core/lib/utilsBundle'; + + import { SigIntWatcher } from './sigIntWatcher'; import { serializeError } from '../util'; + +import type { FullResult, TestError } from '../../types/testReporter'; import type { InternalReporter } from '../reporters/internalReporter'; type TaskPhase = (context: Context, errors: TestError[], softErrors: TestError[]) => Promise | void; diff --git a/packages/playwright/src/runner/tasks.ts b/packages/playwright/src/runner/tasks.ts index 2d0b57f13a..4a1056f6a8 100644 --- a/packages/playwright/src/runner/tasks.ts +++ b/packages/playwright/src/runner/tasks.ts @@ -14,27 +14,34 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; import { promisify } from 'util'; + +import { monotonicTime, removeFolders } from 'playwright-core/lib/utils'; import { debug } from 'playwright-core/lib/utilsBundle'; -import { type ManualPromise, monotonicTime, removeFolders } from 'playwright-core/lib/utils'; -import { Dispatcher, type EnvByProjectId } from './dispatcher'; -import type { TestRunnerPluginRegistration } from '../plugins'; -import { createTestGroups, type TestGroup } from '../runner/testGroups'; -import type { Task } from './taskRunner'; -import { TaskRunner } from './taskRunner'; -import type { FullConfigInternal, FullProjectInternal } from '../common/config'; -import { collectProjectsAndTestFiles, createRootSuite, loadFileSuites, loadGlobalHook } from './loadUtils'; -import { removeDirAndLogToConsole, type Matcher } from '../util'; -import { Suite } from '../common/test'; -import { buildDependentProjects, buildTeardownToSetupsMap, filterProjects } from './projectUtils'; + +import { Dispatcher } from './dispatcher'; import { FailureTracker } from './failureTracker'; -import { detectChangedTestFiles } from './vcs'; -import type { InternalReporter } from '../reporters/internalReporter'; -import { cacheDir } from '../transform/compilationCache'; -import type { FullResult } from '../../types/testReporter'; +import { collectProjectsAndTestFiles, createRootSuite, loadFileSuites, loadGlobalHook } from './loadUtils'; +import { buildDependentProjects, buildTeardownToSetupsMap, filterProjects } from './projectUtils'; import { applySuggestedRebaselines, clearSuggestedRebaselines } from './rebase'; +import { Suite } from '../common/test'; +import { createTestGroups } from '../runner/testGroups'; +import { removeDirAndLogToConsole } from '../util'; +import { TaskRunner } from './taskRunner'; +import { detectChangedTestFiles } from './vcs'; +import { cacheDir } from '../transform/compilationCache'; + +import type { TestGroup } from '../runner/testGroups'; +import type { Matcher } from '../util'; +import type { EnvByProjectId } from './dispatcher'; +import type { TestRunnerPluginRegistration } from '../plugins'; +import type { Task } from './taskRunner'; +import type { FullResult } from '../../types/testReporter'; +import type { FullConfigInternal, FullProjectInternal } from '../common/config'; +import type { InternalReporter } from '../reporters/internalReporter'; +import type { ManualPromise } from 'playwright-core/lib/utils'; const readDirAsync = promisify(fs.readdir); diff --git a/packages/playwright/src/runner/testServer.ts b/packages/playwright/src/runner/testServer.ts index db080728e9..14fa5796d4 100644 --- a/packages/playwright/src/runner/testServer.ts +++ b/packages/playwright/src/runner/testServer.ts @@ -14,32 +14,35 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; + import { installRootRedirect, openTraceInBrowser, openTraceViewerApp, registry, startTraceViewerServer } from 'playwright-core/lib/server'; import { ManualPromise, gracefullyProcessExitDoNotHang, isUnderTest } from 'playwright-core/lib/utils'; -import type { Transport, HttpServer } from 'playwright-core/lib/utils'; -import type * as reporterTypes from '../../types/testReporter'; -import { affectedTestFiles, collectAffectedTestFiles, dependenciesForTestFile } from '../transform/compilationCache'; -import type { ConfigLocation, FullConfigInternal } from '../common/config'; -import { createErrorCollectingReporter, createReporterForTestServer, createReporters } from './reporters'; -import { TestRun, runTasks, createLoadTask, createRunTestsTasks, createReportBeginTask, createListFilesTask, runTasksDeferCleanup, createClearCacheTask, createGlobalSetupTasks, createStartDevServerTask, createApplyRebaselinesTask } from './tasks'; import { open } from 'playwright-core/lib/utilsBundle'; -import ListReporter from '../reporters/list'; + +import { createErrorCollectingReporter, createReporterForTestServer, createReporters } from './reporters'; import { SigIntWatcher } from './sigIntWatcher'; -import { Watcher } from '../fsWatcher'; -import type { ReportEntry, TestServerInterface, TestServerInterfaceEventEmitters } from '../isomorphic/testServerInterface'; -import type { ConfigCLIOverrides } from '../common/ipc'; +import { TestRun, createApplyRebaselinesTask, createClearCacheTask, createGlobalSetupTasks, createListFilesTask, createLoadTask, createReportBeginTask, createRunTestsTasks, createStartDevServerTask, runTasks, runTasksDeferCleanup } from './tasks'; import { loadConfig, resolveConfigLocation, restartWithExperimentalTsEsm } from '../common/configLoader'; -import { webServerPluginsForConfig } from '../plugins/webServerPlugin'; -import type { TraceViewerRedirectOptions, TraceViewerServerOptions } from 'playwright-core/lib/server/trace/viewer/traceViewer'; -import type { TestRunnerPluginRegistration } from '../plugins'; -import { serializeError } from '../util'; +import { Watcher } from '../fsWatcher'; import { baseFullConfig } from '../isomorphic/teleReceiver'; -import { InternalReporter } from '../reporters/internalReporter'; -import type { ReporterV2 } from '../reporters/reporterV2'; -import { internalScreen } from '../reporters/base'; import { addGitCommitInfoPlugin } from '../plugins/gitCommitInfoPlugin'; +import { webServerPluginsForConfig } from '../plugins/webServerPlugin'; +import { internalScreen } from '../reporters/base'; +import { InternalReporter } from '../reporters/internalReporter'; +import ListReporter from '../reporters/list'; +import { affectedTestFiles, collectAffectedTestFiles, dependenciesForTestFile } from '../transform/compilationCache'; +import { serializeError } from '../util'; + +import type * as reporterTypes from '../../types/testReporter'; +import type { ConfigLocation, FullConfigInternal } from '../common/config'; +import type { ConfigCLIOverrides } from '../common/ipc'; +import type { ReportEntry, TestServerInterface, TestServerInterfaceEventEmitters } from '../isomorphic/testServerInterface'; +import type { TestRunnerPluginRegistration } from '../plugins'; +import type { ReporterV2 } from '../reporters/reporterV2'; +import type { TraceViewerRedirectOptions, TraceViewerServerOptions } from 'playwright-core/lib/server/trace/viewer/traceViewer'; +import type { HttpServer, Transport } from 'playwright-core/lib/utils'; const originalStdoutWrite = process.stdout.write; const originalStderrWrite = process.stderr.write; diff --git a/packages/playwright/src/runner/vcs.ts b/packages/playwright/src/runner/vcs.ts index da7c4c2cc8..91d88bc49d 100644 --- a/packages/playwright/src/runner/vcs.ts +++ b/packages/playwright/src/runner/vcs.ts @@ -15,8 +15,9 @@ */ import childProcess from 'child_process'; +import * as path from 'path'; + import { affectedTestFiles } from '../transform/compilationCache'; -import path from 'path'; export async function detectChangedTestFiles(baseCommit: string, configDir: string): Promise> { function gitFileList(command: string) { diff --git a/packages/playwright/src/runner/watchMode.ts b/packages/playwright/src/runner/watchMode.ts index 5c8ddf34a0..c9768c47ba 100644 --- a/packages/playwright/src/runner/watchMode.ts +++ b/packages/playwright/src/runner/watchMode.ts @@ -14,20 +14,25 @@ * limitations under the License. */ +import * as path from 'path'; import readline from 'readline'; -import path from 'path'; -import { createGuid, eventsHelper, getPackageManagerExecCommand, ManualPromise } from 'playwright-core/lib/utils'; -import type { ConfigLocation } from '../common/config'; -import type { FullResult } from '../../types/testReporter'; -import { colors } from 'playwright-core/lib/utilsBundle'; -import { enquirer } from '../utilsBundle'; -import { separator, terminalScreen } from '../reporters/base'; -import { PlaywrightServer } from 'playwright-core/lib/remote/playwrightServer'; -import { TestServerDispatcher } from './testServer'; import { EventEmitter } from 'stream'; -import { type TestServerTransport, TestServerConnection } from '../isomorphic/testServerConnection'; -import { TeleSuiteUpdater } from '../isomorphic/teleSuiteUpdater'; + +import { PlaywrightServer } from 'playwright-core/lib/remote/playwrightServer'; +import { ManualPromise, createGuid, eventsHelper, getPackageManagerExecCommand } from 'playwright-core/lib/utils'; +import { colors } from 'playwright-core/lib/utilsBundle'; + +import { separator, terminalScreen } from '../reporters/base'; +import { enquirer } from '../utilsBundle'; +import { TestServerDispatcher } from './testServer'; import { restartWithExperimentalTsEsm } from '../common/configLoader'; +import { TeleSuiteUpdater } from '../isomorphic/teleSuiteUpdater'; +import { TestServerConnection } from '../isomorphic/testServerConnection'; + +import type { FullResult } from '../../types/testReporter'; +import type { ConfigLocation } from '../common/config'; +import type { TestServerTransport } from '../isomorphic/testServerConnection'; + class InMemoryTransport extends EventEmitter implements TestServerTransport { public readonly _send: (data: string) => void; diff --git a/packages/playwright/src/runner/workerHost.ts b/packages/playwright/src/runner/workerHost.ts index 834dd1facf..d92093e72b 100644 --- a/packages/playwright/src/runner/workerHost.ts +++ b/packages/playwright/src/runner/workerHost.ts @@ -14,15 +14,19 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import type { TestGroup } from './testGroups'; -import { stdioChunkToParams } from '../common/ipc'; -import type { RunPayload, SerializedConfig, WorkerInitParams } from '../common/ipc'; -import { ProcessHost } from './processHost'; -import { artifactsFolderName } from '../isomorphic/folders'; +import * as fs from 'fs'; +import * as path from 'path'; + import { removeFolders } from 'playwright-core/lib/utils'; +import { ProcessHost } from './processHost'; +import { stdioChunkToParams } from '../common/ipc'; +import { artifactsFolderName } from '../isomorphic/folders'; + +import type { TestGroup } from './testGroups'; +import type { RunPayload, SerializedConfig, WorkerInitParams } from '../common/ipc'; + + let lastWorkerIndex = 0; export class WorkerHost extends ProcessHost { diff --git a/packages/playwright/src/transform/babelBundle.ts b/packages/playwright/src/transform/babelBundle.ts index 349b7b9c30..ce61eecc90 100644 --- a/packages/playwright/src/transform/babelBundle.ts +++ b/packages/playwright/src/transform/babelBundle.ts @@ -24,5 +24,5 @@ export type BabelTransformFunction = (code: string, filename: string, isModule: export const babelTransform: BabelTransformFunction = require('./babelBundleImpl').babelTransform; export type BabelParseFunction = (code: string, filename: string, isModule: boolean) => ParseResult; export const babelParse: BabelParseFunction = require('./babelBundleImpl').babelParse; -export type { NodePath, types as T, PluginObj } from '../../bundles/babel/node_modules/@types/babel__core'; +export type { NodePath, PluginObj, types as T } from '../../bundles/babel/node_modules/@types/babel__core'; export type { BabelAPI } from '../../bundles/babel/node_modules/@types/babel__helper-plugin-utils'; diff --git a/packages/playwright/src/transform/compilationCache.ts b/packages/playwright/src/transform/compilationCache.ts index 39c1189ea2..ae9391d79a 100644 --- a/packages/playwright/src/transform/compilationCache.ts +++ b/packages/playwright/src/transform/compilationCache.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -import fs from 'fs'; -import os from 'os'; -import path from 'path'; -import { sourceMapSupport } from '../utilsBundle'; +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; + import { isWorkerProcess } from '../common/globals'; +import { sourceMapSupport } from '../utilsBundle'; export type MemoryCache = { codePath: string; diff --git a/packages/playwright/src/transform/esmLoader.ts b/packages/playwright/src/transform/esmLoader.ts index c84d15146b..6e6b37cf4c 100644 --- a/packages/playwright/src/transform/esmLoader.ts +++ b/packages/playwright/src/transform/esmLoader.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -import fs from 'fs'; -import url from 'url'; +import * as fs from 'fs'; +import * as url from 'url'; + import { addToCompilationCache, currentFileDepsCollector, serializeCompilationCache, startCollectingFileDeps, stopCollectingFileDeps } from './compilationCache'; -import { transformHook, resolveHook, setTransformConfig, shouldTransform, setSingleTSConfig } from './transform'; import { PortTransport } from './portTransport'; +import { resolveHook, setSingleTSConfig, setTransformConfig, shouldTransform, transformHook } from './transform'; import { fileIsModule } from '../util'; // Node < 18.6: defaultResolve takes 3 arguments. @@ -120,4 +121,4 @@ function createTransport(port: MessagePort) { } -module.exports = { resolve, load, globalPreload, initialize }; +module.exports = { globalPreload, initialize, load, resolve }; diff --git a/packages/playwright/src/transform/esmUtils.ts b/packages/playwright/src/transform/esmUtils.ts index 31851f61d3..bfa4a23790 100644 --- a/packages/playwright/src/transform/esmUtils.ts +++ b/packages/playwright/src/transform/esmUtils.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import url from 'url'; +import * as url from 'url'; const kExperimentalLoaderOptions = [ '--no-warnings', diff --git a/packages/playwright/src/transform/transform.ts b/packages/playwright/src/transform/transform.ts index 88950670be..06717dde21 100644 --- a/packages/playwright/src/transform/transform.ts +++ b/packages/playwright/src/transform/transform.ts @@ -15,18 +15,21 @@ */ import crypto from 'crypto'; -import fs from 'fs'; -import path from 'path'; -import url from 'url'; -import { sourceMapSupport, pirates } from '../utilsBundle'; +import * as fs from 'fs'; +import Module from 'module'; +import * as path from 'path'; +import * as url from 'url'; + +import { loadTsConfig } from '../third_party/tsconfig-loader'; +import { createFileMatcher, fileIsModule, resolveImportSpecifierAfterMapping } from '../util'; +import { pirates, sourceMapSupport } from '../utilsBundle'; +import { belongsToNodeModules, currentFileDepsCollector, getFromCompilationCache, installSourceMapSupport } from './compilationCache'; + +import type { BabelPlugin, BabelTransformFunction } from './babelBundle'; import type { Location } from '../../types/testReporter'; import type { LoadedTsConfig } from '../third_party/tsconfig-loader'; -import { loadTsConfig } from '../third_party/tsconfig-loader'; -import Module from 'module'; -import type { BabelPlugin, BabelTransformFunction } from './babelBundle'; -import { createFileMatcher, fileIsModule, resolveImportSpecifierAfterMapping } from '../util'; import type { Matcher } from '../util'; -import { getFromCompilationCache, currentFileDepsCollector, belongsToNodeModules, installSourceMapSupport } from './compilationCache'; + const version = require('../../package.json').version; diff --git a/packages/playwright/src/util.ts b/packages/playwright/src/util.ts index f7f91d3198..74911a85cb 100644 --- a/packages/playwright/src/util.ts +++ b/packages/playwright/src/util.ts @@ -14,17 +14,19 @@ * limitations under the License. */ -import fs from 'fs'; -import type { StackFrame } from '@protocol/channels'; +import * as fs from 'fs'; +import * as path from 'path'; +import * as url from 'url'; import util from 'util'; -import path from 'path'; -import url from 'url'; -import { debug, mime, minimatch, parseStackTraceLine } from 'playwright-core/lib/utilsBundle'; + import { formatCallLog } from 'playwright-core/lib/utils'; -import type { Location } from './../types/testReporter'; import { calculateSha1, isRegExp, isString, sanitizeForFilePath, stringifyStackFrames } from 'playwright-core/lib/utils'; -import type { RawStack } from 'playwright-core/lib/utils'; +import { debug, mime, minimatch, parseStackTraceLine } from 'playwright-core/lib/utilsBundle'; + +import type { Location } from './../types/testReporter'; import type { TestInfoErrorImpl } from './common/ipc'; +import type { StackFrame } from '@protocol/channels'; +import type { RawStack } from 'playwright-core/lib/utils'; const PLAYWRIGHT_TEST_PATH = path.join(__dirname, '..'); const PLAYWRIGHT_CORE_PATH = path.dirname(require.resolve('playwright-core/package.json')); diff --git a/packages/playwright/src/worker/fixtureRunner.ts b/packages/playwright/src/worker/fixtureRunner.ts index f4fc373610..555f86ab57 100644 --- a/packages/playwright/src/worker/fixtureRunner.ts +++ b/packages/playwright/src/worker/fixtureRunner.ts @@ -14,13 +14,16 @@ * limitations under the License. */ -import { formatLocation, filterStackFile } from '../util'; import { ManualPromise } from 'playwright-core/lib/utils'; + +import { fixtureParameterNames } from '../common/fixtures'; +import { filterStackFile, formatLocation } from '../util'; + import type { TestInfoImpl } from './testInfo'; -import { type FixtureDescription, type RunnableDescription } from './timeoutManager'; -import { fixtureParameterNames, type FixturePool, type FixtureRegistration, type FixtureScope } from '../common/fixtures'; +import type { FixtureDescription, RunnableDescription } from './timeoutManager'; import type { WorkerInfo } from '../../types/test'; import type { Location } from '../../types/testReporter'; +import type { FixturePool, FixtureRegistration, FixtureScope } from '../common/fixtures'; class Fixture { runner: FixtureRunner; diff --git a/packages/playwright/src/worker/testInfo.ts b/packages/playwright/src/worker/testInfo.ts index 740f7579bd..5e964af5e0 100644 --- a/packages/playwright/src/worker/testInfo.ts +++ b/packages/playwright/src/worker/testInfo.ts @@ -14,21 +14,25 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import { captureRawStack, monotonicTime, zones, sanitizeForFilePath, stringifyStackFrames } from 'playwright-core/lib/utils'; -import type { TestInfo, TestStatus, FullProject, TestStepInfo } from '../../types/test'; -import type { AttachmentPayload, StepBeginPayload, StepEndPayload, TestInfoErrorImpl, WorkerInitParams } from '../common/ipc'; -import type { TestCase } from '../common/test'; +import * as fs from 'fs'; +import * as path from 'path'; + +import { captureRawStack, monotonicTime, sanitizeForFilePath, stringifyStackFrames, zones } from 'playwright-core/lib/utils'; + import { TimeoutManager, TimeoutManagerError, kMaxDeadline } from './timeoutManager'; -import type { RunnableDescription } from './timeoutManager'; -import type { Annotation, FullConfigInternal, FullProjectInternal } from '../common/config'; -import type { FullConfig, Location } from '../../types/testReporter'; import { debugTest, filteredStackTrace, formatLocation, getContainedPath, normalizeAndSaveAttachment, trimLongString, windowsFilesystemFriendlyLength } from '../util'; import { TestTracing } from './testTracing'; -import type { StackFrame } from '@protocol/channels'; import { testInfoError } from './util'; +import type { RunnableDescription } from './timeoutManager'; +import type { FullProject, TestInfo, TestStatus, TestStepInfo } from '../../types/test'; +import type { FullConfig, Location } from '../../types/testReporter'; +import type { Annotation, FullConfigInternal, FullProjectInternal } from '../common/config'; +import type { AttachmentPayload, StepBeginPayload, StepEndPayload, TestInfoErrorImpl, WorkerInitParams } from '../common/ipc'; +import type { TestCase } from '../common/test'; +import type { StackFrame } from '@protocol/channels'; + + export interface TestStepInternal { complete(result: { error?: Error | unknown, suggestedRebaseline?: string }): void; info: TestStepInfoImpl diff --git a/packages/playwright/src/worker/testTracing.ts b/packages/playwright/src/worker/testTracing.ts index e154d6a649..a90c006616 100644 --- a/packages/playwright/src/worker/testTracing.ts +++ b/packages/playwright/src/worker/testTracing.ts @@ -14,17 +14,20 @@ * limitations under the License. */ +import * as fs from 'fs'; +import * as path from 'path'; + +import { ManualPromise, SerializedFS, calculateSha1, createGuid, monotonicTime } from 'playwright-core/lib/utils'; +import { yauzl, yazl } from 'playwright-core/lib/zipBundle'; + +import { filteredStackTrace } from '../util'; + +import type { TestInfoImpl } from './testInfo'; +import type { PlaywrightWorkerOptions, TestInfo, TraceMode } from '../../types/test'; +import type { TestInfoErrorImpl } from '../common/ipc'; import type { SerializedError, StackFrame } from '@protocol/channels'; import type * as trace from '@trace/trace'; import type EventEmitter from 'events'; -import fs from 'fs'; -import path from 'path'; -import { ManualPromise, calculateSha1, monotonicTime, createGuid, SerializedFS } from 'playwright-core/lib/utils'; -import { yauzl, yazl } from 'playwright-core/lib/zipBundle'; -import { filteredStackTrace } from '../util'; -import type { TestInfo, TraceMode, PlaywrightWorkerOptions } from '../../types/test'; -import type { TestInfoImpl } from './testInfo'; -import type { TestInfoErrorImpl } from '../common/ipc'; export type Attachment = TestInfo['attachments'][0]; export const testTraceEntryName = 'test.trace'; diff --git a/packages/playwright/src/worker/timeoutManager.ts b/packages/playwright/src/worker/timeoutManager.ts index ef7665a650..7018dafcc9 100644 --- a/packages/playwright/src/worker/timeoutManager.ts +++ b/packages/playwright/src/worker/timeoutManager.ts @@ -14,8 +14,9 @@ * limitations under the License. */ -import { colors } from 'playwright-core/lib/utilsBundle'; import { ManualPromise, monotonicTime } from 'playwright-core/lib/utils'; +import { colors } from 'playwright-core/lib/utilsBundle'; + import type { Location } from '../../types/testReporter'; export type TimeSlot = { diff --git a/packages/playwright/src/worker/util.ts b/packages/playwright/src/worker/util.ts index a271f62c48..1f8cbc7d48 100644 --- a/packages/playwright/src/worker/util.ts +++ b/packages/playwright/src/worker/util.ts @@ -14,10 +14,11 @@ * limitations under the License. */ -import type { TestInfoErrorImpl } from '../common/ipc'; import { ExpectError } from '../matchers/matcherHint'; import { serializeError } from '../util'; +import type { TestInfoErrorImpl } from '../common/ipc'; + export function testInfoError(error: Error | any): TestInfoErrorImpl { const result = serializeError(error); if (error instanceof ExpectError) diff --git a/packages/playwright/src/worker/workerMain.ts b/packages/playwright/src/worker/workerMain.ts index 8bd7f3dcd0..5188614271 100644 --- a/packages/playwright/src/worker/workerMain.ts +++ b/packages/playwright/src/worker/workerMain.ts @@ -14,25 +14,27 @@ * limitations under the License. */ -import { colors } from 'playwright-core/lib/utilsBundle'; -import { debugTest, relativeFilePath } from '../util'; -import type { TestBeginPayload, TestEndPayload, RunPayload, DonePayload, WorkerInitParams, TeardownErrorsPayload, TestInfoErrorImpl } from '../common/ipc'; -import { stdioChunkToParams } from '../common/ipc'; -import { setCurrentTestInfo, setIsWorkerProcess } from '../common/globals'; -import { deserializeConfig } from '../common/configLoader'; -import type { Suite, TestCase } from '../common/test'; -import type { Annotation, FullConfigInternal, FullProjectInternal } from '../common/config'; -import { FixtureRunner } from './fixtureRunner'; import { ManualPromise, gracefullyCloseAll, removeFolders } from 'playwright-core/lib/utils'; +import { colors } from 'playwright-core/lib/utilsBundle'; + +import { deserializeConfig } from '../common/configLoader'; +import { setCurrentTestInfo, setIsWorkerProcess } from '../common/globals'; +import { stdioChunkToParams } from '../common/ipc'; +import { debugTest, relativeFilePath } from '../util'; +import { FixtureRunner } from './fixtureRunner'; import { SkipError, TestInfoImpl } from './testInfo'; -import { ProcessRunner } from '../common/process'; -import { loadTestFile } from '../common/testLoader'; -import { applyRepeatEachIndex, bindFileSuiteToProject, filterTestsRemoveEmptySuites } from '../common/suiteUtils'; -import { PoolBuilder } from '../common/poolBuilder'; -import type { Location } from '../../types/testReporter'; -import { inheritFixtureNames } from '../common/fixtures'; -import { type TimeSlot } from './timeoutManager'; import { testInfoError } from './util'; +import { inheritFixtureNames } from '../common/fixtures'; +import { PoolBuilder } from '../common/poolBuilder'; +import { ProcessRunner } from '../common/process'; +import { applyRepeatEachIndex, bindFileSuiteToProject, filterTestsRemoveEmptySuites } from '../common/suiteUtils'; +import { loadTestFile } from '../common/testLoader'; + +import type { TimeSlot } from './timeoutManager'; +import type { Location } from '../../types/testReporter'; +import type { Annotation, FullConfigInternal, FullProjectInternal } from '../common/config'; +import type { DonePayload, RunPayload, TeardownErrorsPayload, TestBeginPayload, TestEndPayload, TestInfoErrorImpl, WorkerInitParams } from '../common/ipc'; +import type { Suite, TestCase } from '../common/test'; export class WorkerMain extends ProcessRunner { private _params: WorkerInitParams; diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.ts index ef839e44cb..f44acbd015 100644 --- a/packages/playwright/types/test.d.ts +++ b/packages/playwright/types/test.d.ts @@ -371,7 +371,7 @@ interface TestProject { * * ```js * import { test, expect } from '@playwright/test'; - * import fs from 'fs'; + * import * as fs from 'fs'; * * test('example test', async ({}, testInfo) => { * const file = testInfo.outputPath('temporary-file.txt'); @@ -1349,7 +1349,7 @@ interface TestConfig { * * ```js * import { test, expect } from '@playwright/test'; - * import fs from 'fs'; + * import * as fs from 'fs'; * * test('example test', async ({}, testInfo) => { * const file = testInfo.outputPath('temporary-file.txt'); @@ -9191,7 +9191,7 @@ export interface TestInfo { * * ```js * import { test, expect } from '@playwright/test'; - * import fs from 'fs'; + * import * as fs from 'fs'; * * test('example test', async ({}, testInfo) => { * const file = testInfo.outputPath('dir', 'temporary-file.txt'); diff --git a/packages/trace-viewer/vite.config.ts b/packages/trace-viewer/vite.config.ts index 00b367bbc8..52b8b8322a 100644 --- a/packages/trace-viewer/vite.config.ts +++ b/packages/trace-viewer/vite.config.ts @@ -17,7 +17,7 @@ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import { bundle } from './bundle'; -import path from 'path'; +import * as path from 'path'; // https://vitejs.dev/config/ export default defineConfig({ diff --git a/packages/trace-viewer/vite.sw.config.ts b/packages/trace-viewer/vite.sw.config.ts index 60e90b96ac..3a6caaae32 100644 --- a/packages/trace-viewer/vite.sw.config.ts +++ b/packages/trace-viewer/vite.sw.config.ts @@ -17,7 +17,7 @@ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import { bundle } from './bundle'; -import path from 'path'; +import * as path from 'path'; // https://vitejs.dev/config/ export default defineConfig({ diff --git a/packages/trace/src/trace.ts b/packages/trace/src/trace.ts index 65843de1ec..54bb48c9da 100644 --- a/packages/trace/src/trace.ts +++ b/packages/trace/src/trace.ts @@ -14,9 +14,9 @@ * limitations under the License. */ -import type { Point, SerializedError, StackFrame } from '@protocol/channels'; -import type { Language } from '../../playwright-core/src/utils/isomorphic/locatorGenerators'; import type { FrameSnapshot, ResourceSnapshot } from './snapshot'; +import type { Language } from '../../playwright-core/src/utils/isomorphic/locatorGenerators'; +import type { Point, SerializedError, StackFrame } from '@protocol/channels'; export type Size = { width: number, height: number };