Socket
Socket
Sign inDemoInstall

@web/test-runner-playwright

Package Overview
Dependencies
Maintainers
7
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web/test-runner-playwright - npm Package Compare versions

Comparing version 0.0.0-canary-20230420104136 to 0.0.0-canary-20231122093600

2

dist/index.d.ts
import { LaunchOptions, devices } from 'playwright';
import * as playwright from 'playwright';
import { PlaywrightLauncher, ProductType, CreateBrowserContextFn, CreatePageFn } from './PlaywrightLauncher';
import { PlaywrightLauncher, ProductType, CreateBrowserContextFn, CreatePageFn } from './PlaywrightLauncher.js';
export { ProductType, playwright };

@@ -5,0 +5,0 @@ export interface PlaywrightLauncherArgs {

@@ -1,31 +0,8 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.playwrightLauncher = exports.devices = exports.PlaywrightLauncher = exports.playwright = void 0;
const playwright_1 = require("playwright");
Object.defineProperty(exports, "devices", { enumerable: true, get: function () { return playwright_1.devices; } });
const playwright = __importStar(require("playwright"));
exports.playwright = playwright;
const PlaywrightLauncher_1 = require("./PlaywrightLauncher");
Object.defineProperty(exports, "PlaywrightLauncher", { enumerable: true, get: function () { return PlaywrightLauncher_1.PlaywrightLauncher; } });
import { devices } from 'playwright';
import * as playwright from 'playwright';
import { PlaywrightLauncher, } from './PlaywrightLauncher.js';
const validProductTypes = ['chromium', 'firefox', 'webkit'];
function playwrightLauncher(args = {}) {
export { playwright };
export { PlaywrightLauncher, devices };
export function playwrightLauncher(args = {}) {
const { product = 'chromium', launchOptions = {}, createBrowserContext = ({ browser }) => browser.newContext(), createPage = ({ context }) => context.newPage(), __experimentalWindowFocus__ = false, concurrency, } = args;

@@ -35,5 +12,4 @@ if (!validProductTypes.includes(product)) {

}
return new PlaywrightLauncher_1.PlaywrightLauncher(product, launchOptions, createBrowserContext, createPage, __experimentalWindowFocus__, concurrency);
return new PlaywrightLauncher(product, launchOptions, createBrowserContext, createPage, __experimentalWindowFocus__, concurrency);
}
exports.playwrightLauncher = playwrightLauncher;
//# sourceMappingURL=index.js.map
import playwright, { Browser, Page, LaunchOptions, BrowserContext } from 'playwright';
import { BrowserLauncher, TestRunnerCoreConfig } from '@web/test-runner-core';
import { PlaywrightLauncherPage } from './PlaywrightLauncherPage';
export declare type ProductType = 'chromium' | 'firefox' | 'webkit';
import { PlaywrightLauncherPage } from './PlaywrightLauncherPage.js';
export type ProductType = 'chromium' | 'firefox' | 'webkit';
interface CreateArgs {

@@ -9,4 +9,4 @@ browser: Browser;

}
export declare type CreateBrowserContextFn = (args: CreateArgs) => BrowserContext | Promise<BrowserContext>;
export declare type CreatePageFn = (args: CreateArgs & {
export type CreateBrowserContextFn = (args: CreateArgs) => BrowserContext | Promise<BrowserContext>;
export type CreatePageFn = (args: CreateArgs & {
context: BrowserContext;

@@ -13,0 +13,0 @@ }) => Promise<Page>;

@@ -1,18 +0,24 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PlaywrightLauncher = void 0;
const playwright_1 = __importDefault(require("playwright"));
const PlaywrightLauncherPage_1 = require("./PlaywrightLauncherPage");
import playwright from 'playwright';
import { PlaywrightLauncherPage } from './PlaywrightLauncherPage.js';
function capitalize(str) {
return `${str[0].toUpperCase()}${str.substring(1)}`;
}
class PlaywrightLauncher {
export class PlaywrightLauncher {
name;
type = 'playwright';
concurrency;
product;
launchOptions;
createBrowserContextFn;
createPageFn;
config;
testFiles;
browser;
debugBrowser;
activePages = new Map();
activeDebugPages = new Map();
testCoveragePerSession = new Map();
__launchBrowserPromise;
__experimentalWindowFocus__;
constructor(product, launchOptions, createBrowserContextFn, createPageFn, __experimentalWindowFocus__, concurrency) {
this.type = 'playwright';
this.activePages = new Map();
this.activeDebugPages = new Map();
this.testCoveragePerSession = new Map();
this.product = product;

@@ -31,7 +37,6 @@ this.launchOptions = launchOptions;

async stop() {
var _a, _b;
if ((_a = this.browser) === null || _a === void 0 ? void 0 : _a.isConnected()) {
if (this.browser?.isConnected()) {
await this.browser.close();
}
if ((_b = this.debugBrowser) === null || _b === void 0 ? void 0 : _b.isConnected()) {
if (this.debugBrowser?.isConnected()) {
await this.debugBrowser.close();

@@ -41,3 +46,2 @@ }

async startSession(sessionId, url) {
var _a;
const browser = await this.getOrStartBrowser();

@@ -47,3 +51,3 @@ const page = await this.createNewPage(browser);

this.testCoveragePerSession.delete(sessionId);
await page.runSession(url, !!((_a = this.config) === null || _a === void 0 ? void 0 : _a.coverage));
await page.runSession(url, !!this.config?.coverage);
}

@@ -58,5 +62,8 @@ isActive(sessionId) {

if (!this.debugBrowser) {
this.debugBrowser = await playwright_1.default[this.product].launch(Object.assign(Object.assign({}, this.launchOptions), {
this.debugBrowser = await playwright[this.product].launch({
...this.launchOptions,
// devtools is only supported on chromium
devtools: this.product === 'chromium', headless: false }));
devtools: this.product === 'chromium',
headless: false,
});
}

@@ -77,3 +84,3 @@ const page = await this.createNewPage(this.debugBrowser);

});
return new PlaywrightLauncherPage_1.PlaywrightLauncherPage(this.config, this.product, this.testFiles, playwrightContext, playwrightPage);
return new PlaywrightLauncherPage(this.config, this.product, this.testFiles, playwrightContext, playwrightPage);
}

@@ -93,9 +100,8 @@ async stopSession(sessionId) {

async getOrStartBrowser() {
var _a;
if (this.__launchBrowserPromise) {
return this.__launchBrowserPromise;
}
if (!this.browser || !((_a = this.browser) === null || _a === void 0 ? void 0 : _a.isConnected())) {
if (!this.browser || !this.browser?.isConnected()) {
this.__launchBrowserPromise = (async () => {
const browser = await playwright_1.default[this.product].launch(this.launchOptions);
const browser = await playwright[this.product].launch(this.launchOptions);
return browser;

@@ -110,4 +116,4 @@ })();

getPage(sessionId) {
var _a, _b, _c;
const page = (_b = (_a = this.activePages.get(sessionId)) === null || _a === void 0 ? void 0 : _a.playwrightPage) !== null && _b !== void 0 ? _b : (_c = this.activeDebugPages.get(sessionId)) === null || _c === void 0 ? void 0 : _c.playwrightPage;
const page = this.activePages.get(sessionId)?.playwrightPage ??
this.activeDebugPages.get(sessionId)?.playwrightPage;
if (!page) {

@@ -119,3 +125,2 @@ throw new Error(`Could not find a page for session ${sessionId}`);

}
exports.PlaywrightLauncher = PlaywrightLauncher;
//# sourceMappingURL=PlaywrightLauncher.js.map
import { Page, BrowserContext } from 'playwright';
import { TestRunnerCoreConfig } from '@web/test-runner-core';
import { SessionResult } from '@web/test-runner-core';
import { ProductType } from './PlaywrightLauncher';
import { ProductType } from './PlaywrightLauncher.js';
export declare class PlaywrightLauncherPage {

@@ -6,0 +6,0 @@ private config;

@@ -1,8 +0,10 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PlaywrightLauncherPage = void 0;
const test_runner_coverage_v8_1 = require("@web/test-runner-coverage-v8");
class PlaywrightLauncherPage {
import { v8ToIstanbul } from '@web/test-runner-coverage-v8';
export class PlaywrightLauncherPage {
config;
testFiles;
product;
playwrightContext;
playwrightPage;
nativeInstrumentationEnabledOnPage = false;
constructor(config, product, testFiles, playwrightContext, playwrightPage) {
this.nativeInstrumentationEnabledOnPage = false;
this.config = config;

@@ -15,6 +17,5 @@ this.product = product;

async runSession(url, coverage) {
var _a;
if (coverage &&
this.product === 'chromium' &&
((_a = this.config.coverageConfig) === null || _a === void 0 ? void 0 : _a.nativeInstrumentation) !== false) {
this.config.coverageConfig?.nativeInstrumentation !== false) {
if (this.nativeInstrumentationEnabledOnPage) {

@@ -40,3 +41,2 @@ await this.playwrightPage.coverage.stopJSCoverage();

async collectTestCoverage(config, testFiles) {
var _a, _b, _c;
const userAgentPromise = this.playwrightPage

@@ -55,3 +55,3 @@ .evaluate(() => window.navigator.userAgent)

}
if (((_a = config.coverageConfig) === null || _a === void 0 ? void 0 : _a.nativeInstrumentation) === false) {
if (config.coverageConfig?.nativeInstrumentation === false) {
throw new Error('Coverage is enabled with nativeInstrumentation disabled. ' +

@@ -64,3 +64,3 @@ 'Expected coverage provided in the browser as a global __coverage__ variable.' +

if (this.product === 'chromium') {
coverage = await ((_c = (_b = this.playwrightPage) === null || _b === void 0 ? void 0 : _b.coverage) === null || _c === void 0 ? void 0 : _c.stopJSCoverage());
coverage = await this.playwrightPage?.coverage?.stopJSCoverage();
}

@@ -72,6 +72,5 @@ else {

const userAgent = await userAgentPromise;
return test_runner_coverage_v8_1.v8ToIstanbul(config, testFiles, coverage, userAgent);
return v8ToIstanbul(config, testFiles, coverage, userAgent);
}
}
exports.PlaywrightLauncherPage = PlaywrightLauncherPage;
//# sourceMappingURL=PlaywrightLauncherPage.js.map
// this file is autogenerated with the generate-mjs-dts-entrypoints script
export * from './dist/index';
export * from './dist/index.js';
{
"name": "@web/test-runner-playwright",
"version": "0.0.0-canary-20230420104136",
"version": "0.0.0-canary-20231122093600",
"publishConfig": {

@@ -17,4 +17,6 @@ "access": "public"

"main": "dist/index.js",
"type": "module",
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.mjs",

@@ -25,3 +27,3 @@ "require": "./dist/index.js"

"engines": {
"node": ">=16.0.0"
"node": ">=18.0.0"
},

@@ -50,10 +52,10 @@ "scripts": {

"dependencies": {
"@web/test-runner-core": "0.0.0-canary-20230420104136",
"@web/test-runner-coverage-v8": "0.0.0-canary-20230420104136",
"@web/test-runner-core": "0.0.0-canary-20231122093600",
"@web/test-runner-coverage-v8": "0.0.0-canary-20231122093600",
"playwright": "^1.22.2"
},
"devDependencies": {
"@web/test-runner-mocha": "0.0.0-canary-20230420104136",
"@web/test-runner-mocha": "0.0.0-canary-20231122093600",
"portfinder": "^1.0.32"
}
}

@@ -8,3 +8,3 @@ import { LaunchOptions, devices } from 'playwright';

CreatePageFn,
} from './PlaywrightLauncher';
} from './PlaywrightLauncher.js';

@@ -11,0 +11,0 @@ const validProductTypes: ProductType[] = ['chromium', 'firefox', 'webkit'];

import playwright, { Browser, Page, LaunchOptions, BrowserContext } from 'playwright';
import { BrowserLauncher, TestRunnerCoreConfig, CoverageMapData } from '@web/test-runner-core';
import { PlaywrightLauncherPage } from './PlaywrightLauncherPage';
import { PlaywrightLauncherPage } from './PlaywrightLauncherPage.js';

@@ -5,0 +5,0 @@ function capitalize(str: string) {

@@ -5,3 +5,3 @@ import { Page, BrowserContext } from 'playwright';

import { SessionResult } from '@web/test-runner-core';
import { ProductType } from './PlaywrightLauncher';
import { ProductType } from './PlaywrightLauncher.js';

@@ -8,0 +8,0 @@ export class PlaywrightLauncherPage {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc