test: have typed playwright-core/* imports
This commit is contained in:
parent
d0c840f639
commit
daf6c40160
|
|
@ -170,7 +170,6 @@ export function createHttpsServer(...args: any[]): https.Server {
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createHttp2Server( onRequestHandler?: (request: http2.Http2ServerRequest, response: http2.Http2ServerResponse) => void,): http2.Http2SecureServer;
|
|
||||||
export function createHttp2Server(options: http2.SecureServerOptions, onRequestHandler?: (request: http2.Http2ServerRequest, response: http2.Http2ServerResponse) => void,): http2.Http2SecureServer;
|
export function createHttp2Server(options: http2.SecureServerOptions, onRequestHandler?: (request: http2.Http2ServerRequest, response: http2.Http2ServerResponse) => void,): http2.Http2SecureServer;
|
||||||
export function createHttp2Server(...args: any[]): http2.Http2SecureServer {
|
export function createHttp2Server(...args: any[]): http2.Http2SecureServer {
|
||||||
const server = http2.createSecureServer(...args);
|
const server = http2.createSecureServer(...args);
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { PNG } from 'playwright-core/lib/utilsBundle';
|
import { PNG } from '@playwright-core/utilsBundle';
|
||||||
|
|
||||||
import { androidTest as test, expect } from './androidTest';
|
import { androidTest as test, expect } from './androidTest';
|
||||||
|
|
||||||
test('androidDevice.shell', async function({ androidDevice }) {
|
test('androidDevice.shell', async function({ androidDevice }) {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import * as os from 'os';
|
||||||
import type { PageTestFixtures, PageWorkerFixtures } from '../page/pageTestApi';
|
import type { PageTestFixtures, PageWorkerFixtures } from '../page/pageTestApi';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import type { BrowserContext, BrowserContextOptions, BrowserType, Page } from 'playwright-core';
|
import type { BrowserContext, BrowserContextOptions, BrowserType, Page } from 'playwright-core';
|
||||||
import { removeFolders } from '../../packages/playwright-core/lib/utils/fileUtils';
|
import { removeFolders } from '@playwright-core/utils';
|
||||||
import { baseTest } from './baseTest';
|
import { baseTest } from './baseTest';
|
||||||
import { type RemoteServerOptions, type PlaywrightServer, RunServer, RemoteServer } from './remoteServer';
|
import { type RemoteServerOptions, type PlaywrightServer, RunServer, RemoteServer } from './remoteServer';
|
||||||
import type { Log } from '../../packages/trace/src/har';
|
import type { Log } from '../../packages/trace/src/har';
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getComparator } from '../../packages/playwright-core/lib/utils/comparators';
|
import { getComparator } from '@playwright-core/utils';
|
||||||
|
|
||||||
const pngComparator = getComparator('image/png');
|
const pngComparator = getComparator('image/png');
|
||||||
type ComparatorResult = { diff?: Buffer; errorMessage: string; } | null;
|
type ComparatorResult = { diff?: Buffer; errorMessage: string; } | null;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import { TestServer } from './testserver';
|
||||||
import { TestProxy } from './proxy';
|
import { TestProxy } from './proxy';
|
||||||
import type { SocksSocketRequestedPayload } from '../../packages/playwright-core/src/common/socksProxy';
|
import type { SocksSocketRequestedPayload } from '../../packages/playwright-core/src/common/socksProxy';
|
||||||
|
|
||||||
import { SocksProxy } from '../../packages/playwright-core/lib/common/socksProxy';
|
import { SocksProxy } from '@playwright-core/common/socksProxy';
|
||||||
|
|
||||||
export type ServerWorkerOptions = {
|
export type ServerWorkerOptions = {
|
||||||
loopback?: string;
|
loopback?: string;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import url from 'url';
|
||||||
import util from 'util';
|
import util from 'util';
|
||||||
import ws from 'ws';
|
import ws from 'ws';
|
||||||
import zlib, { gzip } from 'zlib';
|
import zlib, { gzip } from 'zlib';
|
||||||
import { createHttpServer, createHttpsServer } from '../../../packages/playwright-core/lib/utils/network';
|
import { createHttpServer, createHttpsServer } from '@playwright-core/utils';
|
||||||
|
|
||||||
const fulfillSymbol = Symbol('fulfil callback');
|
const fulfillSymbol = Symbol('fulfil callback');
|
||||||
const rejectSymbol = Symbol('reject callback');
|
const rejectSymbol = Symbol('reject callback');
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Frame, Page } from 'playwright-core';
|
import type { Frame, Page } from 'playwright-core';
|
||||||
import { ZipFile } from '../../packages/playwright-core/lib/utils/zipFile';
|
import { ZipFile } from '@playwright-core/utils';
|
||||||
import type { TraceModelBackend } from '../../packages/trace-viewer/src/traceModel';
|
import type { TraceModelBackend } from '../../packages/trace-viewer/src/traceModel';
|
||||||
import type { StackFrame } from '../../packages/protocol/src/channels';
|
import type { StackFrame } from '../../packages/protocol/src/channels';
|
||||||
import { parseClientSideCallMetadata } from '../../packages/playwright-core/lib/utils/isomorphic/traceUtils';
|
import { parseClientSideCallMetadata } from '@playwright-core/utils/isomorphic/traceUtils';
|
||||||
import { TraceModel } from '../../packages/trace-viewer/src/traceModel';
|
import { TraceModel } from '../../packages/trace-viewer/src/traceModel';
|
||||||
import type { ActionTreeItem } from '../../packages/trace-viewer/src/ui/modelUtil';
|
import type { ActionTreeItem } from '../../packages/trace-viewer/src/ui/modelUtil';
|
||||||
import { buildActionTree, MultiTraceModel } from '../../packages/trace-viewer/src/ui/modelUtil';
|
import { buildActionTree, MultiTraceModel } from '../../packages/trace-viewer/src/ui/modelUtil';
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import { spawnAsync } from '../../packages/playwright-core/lib/utils/spawnAsync';
|
import { spawnAsync } from '@playwright-core/utils';
|
||||||
|
|
||||||
export default async () => {
|
export default async () => {
|
||||||
const result = await spawnAsync('npx', ['electron', require.resolve('./electron-print-chromium-version.js'), '--no-sandbox'], {
|
const result = await spawnAsync('npx', ['electron', require.resolve('./electron-print-chromium-version.js'), '--no-sandbox'], {
|
||||||
|
|
|
||||||
39
tests/global.d.ts
vendored
Normal file
39
tests/global.d.ts
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
declare module '@playwright-core/utils' {
|
||||||
|
const content: typeof import('../packages/playwright-core/src/utils');
|
||||||
|
export = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@playwright-core/utilsBundle' {
|
||||||
|
const content: typeof import('../packages/playwright-core/src/utilsBundle');
|
||||||
|
export = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@playwright-core/common/socksProxy' {
|
||||||
|
const content: typeof import('../packages/playwright-core/src/common/socksProxy');
|
||||||
|
export = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@playwright-core/utils/isomorphic/traceUtils' {
|
||||||
|
const content: typeof import('../packages/playwright-core/src/utils/isomorphic/traceUtils');
|
||||||
|
export = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@playwright-core/utils/isomorphic/locatorGenerators' {
|
||||||
|
const content: typeof import('../packages/playwright-core/src/utils/isomorphic/locatorGenerators');
|
||||||
|
export = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@playwright-core/utils/isomorphic/locatorParser' {
|
||||||
|
const content: typeof import('../packages/playwright-core/src/utils/isomorphic/locatorParser');
|
||||||
|
export = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@playwright-core/utils/isomorphic/cssParser' {
|
||||||
|
const content: typeof import('../packages/playwright-core/src/utils/isomorphic/cssParser');
|
||||||
|
export = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@playwright-core/utils/isomorphic/selectorParser' {
|
||||||
|
const content: typeof import('../packages/playwright-core/src/utils/isomorphic/selectorParser');
|
||||||
|
export = content;
|
||||||
|
}
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { test, expect } from '../playwright-test/stable-test-runner';
|
import { test, expect } from '../playwright-test/stable-test-runner';
|
||||||
import { PNG } from 'playwright-core/lib/utilsBundle';
|
import { PNG } from '@playwright-core/utilsBundle';
|
||||||
import { compare } from 'playwright-core/lib/image_tools/compare';
|
import { compare } from 'playwright-core/lib/image_tools/compare';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { PNG } from 'playwright-core/lib/utilsBundle';
|
import { PNG } from '@playwright-core/utilsBundle';
|
||||||
import { ImageChannel } from 'playwright-core/lib/image_tools/imageChannel';
|
import { ImageChannel } from 'playwright-core/lib/image_tools/imageChannel';
|
||||||
|
|
||||||
// mulberry32
|
// mulberry32
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,7 @@
|
||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { spawnAsync } from '../../packages/playwright-core/lib/utils/spawnAsync';
|
import { spawnAsync, removeFolders } from '@playwright-core/utils';
|
||||||
import { removeFolders } from '../../packages/playwright-core/lib/utils/fileUtils';
|
|
||||||
import { TMP_WORKSPACES } from './npmTest';
|
import { TMP_WORKSPACES } from './npmTest';
|
||||||
|
|
||||||
const PACKAGE_BUILDER_SCRIPT = path.join(__dirname, '..', '..', 'utils', 'pack_package.js');
|
const PACKAGE_BUILDER_SCRIPT = path.join(__dirname, '..', '..', 'utils', 'pack_package.js');
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,7 @@ import debugLogger from 'debug';
|
||||||
import { Registry } from './registry';
|
import { Registry } from './registry';
|
||||||
import type { CommonFixtures, CommonWorkerFixtures } from '../config/commonFixtures';
|
import type { CommonFixtures, CommonWorkerFixtures } from '../config/commonFixtures';
|
||||||
import { commonFixtures } from '../config/commonFixtures';
|
import { commonFixtures } from '../config/commonFixtures';
|
||||||
import { removeFolders } from '../../packages/playwright-core/lib/utils/fileUtils';
|
import { spawnAsync, removeFolders } from '@playwright-core/utils';
|
||||||
import { spawnAsync } from '../../packages/playwright-core/lib/utils/spawnAsync';
|
|
||||||
import type { SpawnOptions } from 'child_process';
|
import type { SpawnOptions } from 'child_process';
|
||||||
|
|
||||||
export const TMP_WORKSPACES = path.join(os.platform() === 'darwin' ? '/tmp' : os.tmpdir(), 'pwt', 'workspaces');
|
export const TMP_WORKSPACES = path.join(os.platform() === 'darwin' ? '/tmp' : os.tmpdir(), 'pwt', 'workspaces');
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,7 @@ import type { Server } from 'http';
|
||||||
import type http from 'http';
|
import type http from 'http';
|
||||||
import https from 'https';
|
import https from 'https';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { spawnAsync } from '../../packages/playwright-core/lib/utils/spawnAsync';
|
import { spawnAsync, createHttpServer } from '@playwright-core/utils';
|
||||||
import { createHttpServer } from '../../packages/playwright-core/lib/utils/network';
|
|
||||||
|
|
||||||
const kPublicNpmRegistry = 'https://registry.npmjs.org';
|
const kPublicNpmRegistry = 'https://registry.npmjs.org';
|
||||||
const kContentTypeAbbreviatedMetadata = 'application/vnd.npm.install-v1+json';
|
const kContentTypeAbbreviatedMetadata = 'application/vnd.npm.install-v1+json';
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,13 @@ import os from 'os';
|
||||||
import type http from 'http';
|
import type http from 'http';
|
||||||
import type net from 'net';
|
import type net from 'net';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { getUserAgent, getPlaywrightVersion } from '../../packages/playwright-core/lib/utils/userAgent';
|
import { getUserAgent, getPlaywrightVersion } from '@playwright-core/utils';
|
||||||
import WebSocket from 'ws';
|
import WebSocket from 'ws';
|
||||||
import { expect, playwrightTest } from '../config/browserTest';
|
import { expect, playwrightTest } from '../config/browserTest';
|
||||||
import { parseTrace, suppressCertificateWarning } from '../config/utils';
|
import { parseTrace, suppressCertificateWarning } from '../config/utils';
|
||||||
import formidable from 'formidable';
|
import formidable from 'formidable';
|
||||||
import type { Browser, ConnectOptions } from 'playwright-core';
|
import type { Browser, ConnectOptions } from 'playwright-core';
|
||||||
import { createHttpServer } from '../../packages/playwright-core/lib/utils/network';
|
import { createHttpServer } from '@playwright-core/utils';
|
||||||
import { kTargetClosedErrorMessage } from '../config/errors';
|
import { kTargetClosedErrorMessage } from '../config/errors';
|
||||||
import { RunServer } from '../config/remoteServer';
|
import { RunServer } from '../config/remoteServer';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
import { playwrightTest as test, expect } from '../../config/browserTest';
|
import { playwrightTest as test, expect } from '../../config/browserTest';
|
||||||
import http from 'http';
|
import http from 'http';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { getUserAgent } from '../../../packages/playwright-core/lib/utils/userAgent';
|
import { getUserAgent } from '@playwright-core/utils';
|
||||||
import { suppressCertificateWarning } from '../../config/utils';
|
import { suppressCertificateWarning } from '../../config/utils';
|
||||||
|
|
||||||
test.skip(({ mode }) => mode === 'service2');
|
test.skip(({ mode }) => mode === 'service2');
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import type http from 'http';
|
||||||
import { expect, playwrightTest as base } from '../config/browserTest';
|
import { expect, playwrightTest as base } from '../config/browserTest';
|
||||||
import type net from 'net';
|
import type net from 'net';
|
||||||
import type { BrowserContextOptions } from 'packages/playwright-test';
|
import type { BrowserContextOptions } from 'packages/playwright-test';
|
||||||
const { createHttpsServer, createHttp2Server } = require('../../packages/playwright-core/lib/utils');
|
import { createHttpsServer, createHttp2Server } from '@playwright-core/utils';
|
||||||
|
|
||||||
type TestOptions = {
|
type TestOptions = {
|
||||||
startCCServer(options?: {
|
startCCServer(options?: {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
import { playwrightTest as it, expect } from '../config/browserTest';
|
import { playwrightTest as it, expect } from '../config/browserTest';
|
||||||
import type { AttributeSelector } from '../../packages/playwright-core/src/utils/isomorphic/selectorParser';
|
import type { AttributeSelector } from '../../packages/playwright-core/src/utils/isomorphic/selectorParser';
|
||||||
import { parseAttributeSelector } from '../../packages/playwright-core/lib/utils/isomorphic/selectorParser';
|
import { parseAttributeSelector } from '@playwright-core/utils/isomorphic/selectorParser';
|
||||||
|
|
||||||
const parse = (selector: string) => parseAttributeSelector(selector, false);
|
const parse = (selector: string) => parseAttributeSelector(selector, false);
|
||||||
const serialize = (parsed: AttributeSelector) => {
|
const serialize = (parsed: AttributeSelector) => {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { playwrightTest as it, expect } from '../config/browserTest';
|
import { playwrightTest as it, expect } from '../config/browserTest';
|
||||||
import { parseCSS, serializeSelector as serialize } from '../../packages/playwright-core/lib/utils/isomorphic/cssParser';
|
import { parseCSS, serializeSelector as serialize } from '@playwright-core/utils/isomorphic/cssParser';
|
||||||
|
|
||||||
const parse = (selector: string) => {
|
const parse = (selector: string) => {
|
||||||
return parseCSS(selector, new Set(['text', 'not', 'has', 'react', 'scope', 'right-of', 'is'])).selector;
|
return parseCSS(selector, new Set(['text', 'not', 'has', 'react', 'scope', 'right-of', 'is'])).selector;
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
import { expect, playwrightTest as baseTest } from '../config/browserTest';
|
import { expect, playwrightTest as baseTest } from '../config/browserTest';
|
||||||
import { PlaywrightServer } from '../../packages/playwright-core/lib/remote/playwrightServer';
|
import { PlaywrightServer } from '../../packages/playwright-core/lib/remote/playwrightServer';
|
||||||
import { createGuid } from '../../packages/playwright-core/lib/utils/crypto';
|
import { createGuid } from '@playwright-core/utils';
|
||||||
import { Backend } from '../config/debugControllerBackend';
|
import { Backend } from '../config/debugControllerBackend';
|
||||||
import type { Browser, BrowserContext } from '@playwright/test';
|
import type { Browser, BrowserContext } from '@playwright/test';
|
||||||
import type * as channels from '@protocol/channels';
|
import type * as channels from '@protocol/channels';
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
import events from 'events';
|
import events from 'events';
|
||||||
import { EventEmitter } from '../../../packages/playwright-core/lib/client/eventEmitter';
|
import { EventEmitter } from '../../../packages/playwright-core/lib/client/eventEmitter';
|
||||||
import { setUnderTest } from '../../../packages/playwright-core/lib/utils/debug';
|
import { setUnderTest } from '@playwright-core/utils';
|
||||||
import { test, expect } from '@playwright/test';
|
import { test, expect } from '@playwright/test';
|
||||||
import * as common from './utils';
|
import * as common from './utils';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import * as util from 'util';
|
import util from 'util';
|
||||||
import { getPlaywrightVersion } from '../../packages/playwright-core/lib/utils/userAgent';
|
import { getPlaywrightVersion } from '@playwright-core/utils';
|
||||||
import { expect, playwrightTest as base } from '../config/browserTest';
|
import { expect, playwrightTest as base } from '../config/browserTest';
|
||||||
import { kTargetClosedErrorMessage } from 'tests/config/errors';
|
import { kTargetClosedErrorMessage } from 'tests/config/errors';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import type { BrowserContext, BrowserContextOptions } from 'playwright-core';
|
||||||
import type { AddressInfo } from 'net';
|
import type { AddressInfo } from 'net';
|
||||||
import type { Log } from '../../packages/trace/src/har';
|
import type { Log } from '../../packages/trace/src/har';
|
||||||
import { parseHar } from '../config/utils';
|
import { parseHar } from '../config/utils';
|
||||||
const { createHttp2Server } = require('../../packages/playwright-core/lib/utils');
|
import { createHttp2Server } from '@playwright-core/utils';
|
||||||
|
|
||||||
async function pageWithHar(contextFactory: (options?: BrowserContextOptions) => Promise<BrowserContext>, testInfo: any, options: { outputPath?: string, content?: 'embed' | 'attach' | 'omit', omitContent?: boolean } = {}) {
|
async function pageWithHar(contextFactory: (options?: BrowserContextOptions) => Promise<BrowserContext>, testInfo: any, options: { outputPath?: string, content?: 'embed' | 'attach' | 'omit', omitContent?: boolean } = {}) {
|
||||||
const harPath = testInfo.outputPath(options.outputPath || 'test.har');
|
const harPath = testInfo.outputPath(options.outputPath || 'test.har');
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { compare } from 'playwright-core/lib/image_tools/compare';
|
import { compare } from 'playwright-core/lib/image_tools/compare';
|
||||||
import { PNG } from 'playwright-core/lib/utilsBundle';
|
import { PNG } from '@playwright-core/utilsBundle';
|
||||||
import { expect, playwrightTest as it } from '../config/browserTest';
|
import { expect, playwrightTest as it } from '../config/browserTest';
|
||||||
|
|
||||||
it.use({ headless: false });
|
it.use({ headless: false });
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { contextTest as it, expect } from '../config/browserTest';
|
import { contextTest as it, expect } from '../config/browserTest';
|
||||||
import { asLocator, asLocators } from '../../packages/playwright-core/lib/utils/isomorphic/locatorGenerators';
|
import { asLocator, asLocators } from '@playwright-core/utils/isomorphic/locatorGenerators';
|
||||||
import { locatorOrSelectorAsSelector as parseLocator } from '../../packages/playwright-core/lib/utils/isomorphic/locatorParser';
|
import { locatorOrSelectorAsSelector as parseLocator } from '@playwright-core/utils/isomorphic/locatorParser';
|
||||||
import type { Page, Frame, Locator, FrameLocator } from 'playwright-core';
|
import type { Page, Frame, Locator, FrameLocator } from 'playwright-core';
|
||||||
|
|
||||||
it.skip(({ mode }) => mode !== 'default');
|
it.skip(({ mode }) => mode !== 'default');
|
||||||
|
|
@ -27,7 +27,7 @@ function generate(locator: Locator | FrameLocator) {
|
||||||
|
|
||||||
function generateForSelector(selector: string) {
|
function generateForSelector(selector: string) {
|
||||||
const result: any = {};
|
const result: any = {};
|
||||||
for (const lang of ['javascript', 'python', 'java', 'csharp']) {
|
for (const lang of ['javascript', 'python', 'java', 'csharp'] as const) {
|
||||||
const locatorString = asLocator(lang, selector, false);
|
const locatorString = asLocator(lang, selector, false);
|
||||||
expect.soft(parseLocator(lang, locatorString, 'data-testid'), lang + ' mismatch').toBe(selector);
|
expect.soft(parseLocator(lang, locatorString, 'data-testid'), lang + ' mismatch').toBe(selector);
|
||||||
result[lang] = locatorString;
|
result[lang] = locatorString;
|
||||||
|
|
@ -38,9 +38,9 @@ function generateForSelector(selector: string) {
|
||||||
async function generateForNode(pageOrFrame: Page | Frame, target: string): Promise<string> {
|
async function generateForNode(pageOrFrame: Page | Frame, target: string): Promise<string> {
|
||||||
const selector = await pageOrFrame.locator(target).evaluate(e => (window as any).playwright.selector(e));
|
const selector = await pageOrFrame.locator(target).evaluate(e => (window as any).playwright.selector(e));
|
||||||
const result: any = {};
|
const result: any = {};
|
||||||
for (const lang of ['javascript', 'python', 'java', 'csharp']) {
|
for (const lang of ['javascript', 'python', 'java', 'csharp'] as const) {
|
||||||
const locatorString = asLocator(lang, selector, false);
|
const locatorString = asLocator(lang, selector, false);
|
||||||
expect.soft(parseLocator(lang, locatorString)).toBe(selector);
|
expect.soft(parseLocator(lang, locatorString, 'data-testid')).toBe(selector);
|
||||||
result[lang] = locatorString;
|
result[lang] = locatorString;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -563,24 +563,24 @@ it('parse locators strictly', () => {
|
||||||
const selector = 'div >> internal:has-text=\"Goodbye world\"i >> span';
|
const selector = 'div >> internal:has-text=\"Goodbye world\"i >> span';
|
||||||
|
|
||||||
// Exact
|
// Exact
|
||||||
expect.soft(parseLocator('csharp', `Locator("div").Filter(new() { HasText = "Goodbye world" }).Locator("span")`)).toBe(selector);
|
expect.soft(parseLocator('csharp', `Locator("div").Filter(new() { HasText = "Goodbye world" }).Locator("span")`, 'data-testid')).toBe(selector);
|
||||||
expect.soft(parseLocator('java', `locator("div").filter(new Locator.FilterOptions().setHasText("Goodbye world")).locator("span")`)).toBe(selector);
|
expect.soft(parseLocator('java', `locator("div").filter(new Locator.FilterOptions().setHasText("Goodbye world")).locator("span")`, 'data-testid')).toBe(selector);
|
||||||
expect.soft(parseLocator('javascript', `locator('div').filter({ hasText: 'Goodbye world' }).locator('span')`)).toBe(selector);
|
expect.soft(parseLocator('javascript', `locator('div').filter({ hasText: 'Goodbye world' }).locator('span')`, 'data-testid')).toBe(selector);
|
||||||
expect.soft(parseLocator('python', `locator("div").filter(has_text="Goodbye world").locator("span")`)).toBe(selector);
|
expect.soft(parseLocator('python', `locator("div").filter(has_text="Goodbye world").locator("span")`, 'data-testid')).toBe(selector);
|
||||||
|
|
||||||
// Quotes
|
// Quotes
|
||||||
expect.soft(parseLocator('javascript', `locator("div").filter({ hasText: "Goodbye world" }).locator("span")`)).toBe(selector);
|
expect.soft(parseLocator('javascript', `locator("div").filter({ hasText: "Goodbye world" }).locator("span")`, 'data-testid')).toBe(selector);
|
||||||
expect.soft(parseLocator('python', `locator('div').filter(has_text='Goodbye world').locator('span')`)).not.toBe(selector);
|
expect.soft(parseLocator('python', `locator('div').filter(has_text='Goodbye world').locator('span')`, 'data-testid')).not.toBe(selector);
|
||||||
|
|
||||||
// Whitespace
|
// Whitespace
|
||||||
expect.soft(parseLocator('csharp', `Locator("div") . Filter (new ( ) { HasText = "Goodbye world" }).Locator( "span" )`)).toBe(selector);
|
expect.soft(parseLocator('csharp', `Locator("div") . Filter (new ( ) { HasText = "Goodbye world" }).Locator( "span" )`, 'data-testid')).toBe(selector);
|
||||||
expect.soft(parseLocator('java', ` locator("div" ). filter( new Locator. FilterOptions ( ) .setHasText( "Goodbye world" ) ).locator( "span")`)).toBe(selector);
|
expect.soft(parseLocator('java', ` locator("div" ). filter( new Locator. FilterOptions ( ) .setHasText( "Goodbye world" ) ).locator( "span")`, 'data-testid')).toBe(selector);
|
||||||
expect.soft(parseLocator('javascript', `locator\n('div')\n\n.filter({ hasText : 'Goodbye world'\n }\n).locator('span')\n`)).toBe(selector);
|
expect.soft(parseLocator('javascript', `locator\n('div')\n\n.filter({ hasText : 'Goodbye world'\n }\n).locator('span')\n`, 'data-testid')).toBe(selector);
|
||||||
expect.soft(parseLocator('python', `\tlocator(\t"div").filter(\thas_text="Goodbye world"\t).locator\t("span")`)).toBe(selector);
|
expect.soft(parseLocator('python', `\tlocator(\t"div").filter(\thas_text="Goodbye world"\t).locator\t("span")`, 'data-testid')).toBe(selector);
|
||||||
|
|
||||||
// Extra symbols
|
// Extra symbols
|
||||||
expect.soft(parseLocator('csharp', `Locator("div").Filter(new() { HasText = "Goodbye world" }).Locator("span"))`)).not.toBe(selector);
|
expect.soft(parseLocator('csharp', `Locator("div").Filter(new() { HasText = "Goodbye world" }).Locator("span"))`, 'data-testid')).not.toBe(selector);
|
||||||
expect.soft(parseLocator('java', `locator("div").filter(new Locator.FilterOptions().setHasText("Goodbye world"))..locator("span")`)).not.toBe(selector);
|
expect.soft(parseLocator('java', `locator("div").filter(new Locator.FilterOptions().setHasText("Goodbye world"))..locator("span")`, 'data-testid')).not.toBe(selector);
|
||||||
expect.soft(parseLocator('javascript', `locator('div').filter({ hasText: 'Goodbye world' }}).locator('span')`)).not.toBe(selector);
|
expect.soft(parseLocator('javascript', `locator('div').filter({ hasText: 'Goodbye world' }}).locator('span')`, 'data-testid')).not.toBe(selector);
|
||||||
expect.soft(parseLocator('python', `locator("div").filter(has_text=="Goodbye world").locator("span")`)).not.toBe(selector);
|
expect.soft(parseLocator('python', `locator("div").filter(has_text=="Goodbye world").locator("span")`, 'data-testid')).not.toBe(selector);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { expect, browserTest } from '../config/browserTest';
|
import { expect, browserTest } from '../config/browserTest';
|
||||||
import { PNG } from 'playwright-core/lib/utilsBundle';
|
import { PNG } from '@playwright-core/utilsBundle';
|
||||||
import { verifyViewport } from '../config/utils';
|
import { verifyViewport } from '../config/utils';
|
||||||
|
|
||||||
browserTest.describe('page screenshot', () => {
|
browserTest.describe('page screenshot', () => {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { jpegjs } from 'playwright-core/lib/utilsBundle';
|
import { jpegjs } from '@playwright-core/utilsBundle';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { browserTest, contextTest as test, expect } from '../config/browserTest';
|
import { browserTest, contextTest as test, expect } from '../config/browserTest';
|
||||||
import { parseTraceRaw } from '../config/utils';
|
import { parseTraceRaw } from '../config/utils';
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import type { Page } from 'playwright-core';
|
import type { Page } from 'playwright-core';
|
||||||
import { spawnSync } from 'child_process';
|
import { spawnSync } from 'child_process';
|
||||||
import { PNG, jpegjs } from 'playwright-core/lib/utilsBundle';
|
import { PNG, jpegjs } from '@playwright-core/utilsBundle';
|
||||||
import { registry } from '../../packages/playwright-core/lib/server';
|
import { registry } from '../../packages/playwright-core/lib/server';
|
||||||
import { rewriteErrorMessage } from '../../packages/playwright-core/lib/utils/stackTrace';
|
import { rewriteErrorMessage } from '@playwright-core/utils';
|
||||||
import { parseTraceRaw } from '../config/utils';
|
import { parseTraceRaw } from '../config/utils';
|
||||||
|
|
||||||
const ffmpeg = registry.findExecutable('ffmpeg')!.executablePath('javascript');
|
const ffmpeg = registry.findExecutable('ffmpeg')!.executablePath('javascript');
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { test as it, expect } from './pageTest';
|
import { test as it, expect } from './pageTest';
|
||||||
import { globToRegex } from '../../packages/playwright-core/lib/utils/glob';
|
import { globToRegex } from '@playwright-core/utils';
|
||||||
import vm from 'vm';
|
import vm from 'vm';
|
||||||
|
|
||||||
it('should work with navigation @smoke', async ({ page, server }) => {
|
it('should work with navigation @smoke', async ({ page, server }) => {
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { MultiMap } from '../../packages/playwright-core/lib/utils/multimap';
|
import { MultiMap } from '@playwright-core/utils';
|
||||||
import { test, expect } from './pageTest';
|
import { test, expect } from './pageTest';
|
||||||
|
|
||||||
function leakedJSHandles(): string {
|
function leakedJSHandles(): string {
|
||||||
const map = new MultiMap();
|
const map = new MultiMap<Error, string>();
|
||||||
for (const [h, e] of (globalThis as any).leakedJSHandles) {
|
for (const [h, e] of (globalThis as any).leakedJSHandles) {
|
||||||
const name = `[${h.worldNameForTest()}] ${h.preview()}`;
|
const name = `[${h.worldNameForTest()}] ${h.preview()}`;
|
||||||
if (name === '[main] UtilityScript' || name === '[utility] UtilityScript' || name === '[electron] UtilityScript' || name === '[main] InjectedScript' || name === '[utility] InjectedScript' || name === '[electron] ElectronModule')
|
if (name === '[main] UtilityScript' || name === '[utility] UtilityScript' || name === '[electron] UtilityScript' || name === '[main] InjectedScript' || name === '[utility] InjectedScript' || name === '[electron] ElectronModule')
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { test, expect, parseTestRunnerOutput, stripAnsi } from './playwright-test-fixtures';
|
import { test, expect, parseTestRunnerOutput, stripAnsi } from './playwright-test-fixtures';
|
||||||
const { spawnAsync } = require('../../packages/playwright-core/lib/utils');
|
import { spawnAsync } from '@playwright-core/utils';
|
||||||
|
|
||||||
test('should be able to call expect.extend in config', async ({ runInlineTest }) => {
|
test('should be able to call expect.extend in config', async ({ runInlineTest }) => {
|
||||||
const result = await runInlineTest({
|
const result = await runInlineTest({
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import type { JSONReport, JSONReportSpec, JSONReportSuite, JSONReportTest, JSONR
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { PNG } from 'playwright-core/lib/utilsBundle';
|
import { PNG } from '@playwright-core/utilsBundle';
|
||||||
import type { CommonFixtures, CommonWorkerFixtures, TestChildProcess } from '../config/commonFixtures';
|
import type { CommonFixtures, CommonWorkerFixtures, TestChildProcess } from '../config/commonFixtures';
|
||||||
import { commonFixtures } from '../config/commonFixtures';
|
import { commonFixtures } from '../config/commonFixtures';
|
||||||
import type { ServerFixtures, ServerWorkerOptions } from '../config/serverFixtures';
|
import type { ServerFixtures, ServerWorkerOptions } from '../config/serverFixtures';
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import { startHtmlReportServer } from '../../packages/playwright/lib/reporters/h
|
||||||
import { expect as baseExpect, test as baseTest, stripAnsi } from './playwright-test-fixtures';
|
import { expect as baseExpect, test as baseTest, stripAnsi } from './playwright-test-fixtures';
|
||||||
import extractZip from '../../packages/playwright-core/bundles/zip/node_modules/extract-zip';
|
import extractZip from '../../packages/playwright-core/bundles/zip/node_modules/extract-zip';
|
||||||
import * as yazl from '../../packages/playwright-core/bundles/zip/node_modules/yazl';
|
import * as yazl from '../../packages/playwright-core/bundles/zip/node_modules/yazl';
|
||||||
import { getUserAgent } from '../../packages/playwright-core/lib/utils/userAgent';
|
import { getUserAgent } from '@playwright-core/utils';
|
||||||
import { Readable } from 'stream';
|
import { Readable } from 'stream';
|
||||||
|
|
||||||
const DOES_NOT_SUPPORT_UTF8_IN_TERMINAL = process.platform === 'win32' && process.env.TERM_PROGRAM !== 'vscode' && !process.env.WT_SESSION;
|
const DOES_NOT_SUPPORT_UTF8_IN_TERMINAL = process.platform === 'win32' && process.env.TERM_PROGRAM !== 'vscode' && !process.env.WT_SESSION;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import { test as baseTest, expect as baseExpect, createImage } from './playwrigh
|
||||||
import type { HttpServer } from '../../packages/playwright-core/src/utils';
|
import type { HttpServer } from '../../packages/playwright-core/src/utils';
|
||||||
import { startHtmlReportServer } from '../../packages/playwright/lib/reporters/html';
|
import { startHtmlReportServer } from '../../packages/playwright/lib/reporters/html';
|
||||||
import { msToString } from '../../packages/web/src/uiUtils';
|
import { msToString } from '../../packages/web/src/uiUtils';
|
||||||
const { spawnAsync } = require('../../packages/playwright-core/lib/utils');
|
import { spawnAsync } from '@playwright-core/utils';
|
||||||
|
|
||||||
const test = baseTest.extend<{ showReport: (reportFolder?: string) => Promise<void> }>({
|
const test = baseTest.extend<{ showReport: (reportFolder?: string) => Promise<void> }>({
|
||||||
showReport: async ({ page }, use, testInfo) => {
|
showReport: async ({ page }, use, testInfo) => {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import { PNG } from 'playwright-core/lib/utilsBundle';
|
import { PNG } from '@playwright-core/utilsBundle';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { pathToFileURL } from 'url';
|
import { pathToFileURL } from 'url';
|
||||||
import { test, expect, createImage, paintBlackPixels } from './playwright-test-fixtures';
|
import { test, expect, createImage, paintBlackPixels } from './playwright-test-fixtures';
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ManualPromise } from '../../packages/playwright-core/lib/utils/manualPromise';
|
import { ManualPromise } from '@playwright-core/utils';
|
||||||
import { test, expect, retries, dumpTestTree } from './ui-mode-fixtures';
|
import { test, expect, retries, dumpTestTree } from './ui-mode-fixtures';
|
||||||
|
|
||||||
test.describe.configure({ mode: 'parallel', retries });
|
test.describe.configure({ mode: 'parallel', retries });
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
import type http from 'http';
|
import type http from 'http';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { test, expect, parseTestRunnerOutput } from './playwright-test-fixtures';
|
import { test, expect, parseTestRunnerOutput } from './playwright-test-fixtures';
|
||||||
import { createHttpServer } from '../../packages/playwright-core/lib/utils/network';
|
import { createHttpServer } from '@playwright-core/utils';
|
||||||
|
|
||||||
const SIMPLE_SERVER_PATH = path.join(__dirname, 'assets', 'simple-server.js');
|
const SIMPLE_SERVER_PATH = path.join(__dirname, 'assets', 'simple-server.js');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,9 @@
|
||||||
"@recorder/*": ["packages/recorder/src/*"],
|
"@recorder/*": ["packages/recorder/src/*"],
|
||||||
"@trace/*": ["packages/trace/src/*"],
|
"@trace/*": ["packages/trace/src/*"],
|
||||||
"@web/*": ["packages/web/src/*"],
|
"@web/*": ["packages/web/src/*"],
|
||||||
|
"@playwright-core/*": ["packages/playwright-core/lib/*"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"include": ["**/*.spec.js", "**/*.ts"],
|
"include": ["**/*.spec.js", "**/*.ts", "global.d.ts"],
|
||||||
"exclude": ["components/", "installation/fixture-scripts/"]
|
"exclude": ["components/", "installation/fixture-scripts/"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue