Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@web/test-runner-chrome

Package Overview
Dependencies
Maintainers
7
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.6.8 to 0.7.0

15

CHANGELOG.md
# @web/test-runner-chrome
## 0.7.0
### Minor Changes
- 2291ca1: replaced HTTP with websocket for server-browser communication
this improves test speed, especially when a test file makes a lot of concurrent requests
it lets us us catch more errors during test execution, and makes us catch them faster
### Patch Changes
- Updated dependencies [2291ca1]
- @web/test-runner-core@0.8.0
- @web/test-runner-coverage-v8@0.2.0
## 0.6.8

@@ -4,0 +19,0 @@

1

dist/ChromeLauncher.d.ts

@@ -30,2 +30,3 @@ import * as puppeteerCore from 'puppeteer-core';

isActive(sessionId: string): boolean;
getBrowserUrl(sessionId: string): string;
startDebugSession(sessionId: string, url: string): Promise<void>;

@@ -32,0 +33,0 @@ createNewPage(browser: Browser): Promise<ChromeLauncherPage>;

@@ -94,2 +94,5 @@ "use strict";

}
getBrowserUrl(sessionId) {
return this.getPage(sessionId).url();
}
async startDebugSession(sessionId, url) {

@@ -96,0 +99,0 @@ if (!this.debugBrowser) {

2

dist/ChromeLauncherPage.d.ts

@@ -10,4 +10,2 @@ import { Page } from 'puppeteer-core';

private nativeInstrumentationEnabledOnPage;
private testURL?;
private navigations;
constructor(config: TestRunnerCoreConfig, testFiles: string[], product: string, puppeteerPage: Page);

@@ -14,0 +12,0 @@ runSession(url: string, coverage: boolean): Promise<void>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChromeLauncherPage = void 0;
const test_runner_core_1 = require("@web/test-runner-core");
const test_runner_coverage_v8_1 = require("@web/test-runner-coverage-v8");

@@ -9,3 +8,2 @@ class ChromeLauncherPage {

this.nativeInstrumentationEnabledOnPage = false;
this.navigations = [];
this.config = config;

@@ -15,13 +13,5 @@ this.testFiles = testFiles;

this.puppeteerPage = puppeteerPage;
// track browser navigations
puppeteerPage.on('request', e => {
if (e.isNavigationRequest()) {
this.navigations.push(new URL(e.url()));
}
});
}
async runSession(url, coverage) {
var _a;
this.testURL = new URL(url);
this.navigations = [];
if (coverage &&

@@ -40,24 +30,20 @@ ((_a = this.config.coverageConfig) === null || _a === void 0 ? void 0 : _a.nativeInstrumentation) !== false &&

async stopSession() {
const errors = [];
let testCoverage;
// check if the page was navigated, resulting in broken tests
const navigationError = test_runner_core_1.getBrowserPageNavigationError(this.testURL, this.navigations);
if (navigationError) {
errors.push(navigationError);
}
else {
testCoverage = await this.collectTestCoverage(this.config, this.testFiles);
}
const testCoverage = await this.collectTestCoverage(this.config, this.testFiles);
// navigate to an empty page to kill any running code on the page, stopping timers and
// breaking a potential endless reload loop
await this.puppeteerPage.goto('data:,');
return { testCoverage, errors };
return { testCoverage };
}
async collectTestCoverage(config, testFiles) {
var _a, _b, _c, _d, _e;
const coverageFromBrowser = await this.puppeteerPage.evaluate(() => window.__coverage__);
if (coverageFromBrowser) {
// coverage was generated by JS, return that
return coverageFromBrowser;
try {
const coverageFromBrowser = await this.puppeteerPage.evaluate(() => window.__coverage__);
if (coverageFromBrowser) {
// coverage was generated by JS, return that
return coverageFromBrowser;
}
}
catch (error) {
// evaluate throws when the a test navigates in the browser
}
if (((_a = config.coverageConfig) === null || _a === void 0 ? void 0 : _a.nativeInstrumentation) === false) {

@@ -64,0 +50,0 @@ throw new Error('Coverage is enabled with nativeInstrumentation disabled. ' +

{
"name": "@web/test-runner-chrome",
"version": "0.6.8",
"version": "0.7.0",
"publishConfig": {

@@ -22,4 +22,4 @@ "access": "public"

"build": "tsc",
"test": "mocha test/**/*.test.ts --require ts-node/register --reporter dot",
"test:watch": "mocha test/**/*.test.ts --require ts-node/register --watch --watch-files src,test --reporter dot"
"test": "mocha test/**/*.test.ts --require ts-node/register",
"test:watch": "mocha test/**/*.test.ts --require ts-node/register --watch --watch-files src,test"
},

@@ -44,6 +44,6 @@ "files": [

"@types/puppeteer-core": "^2.0.0",
"@web/test-runner-core": "^0.7.19",
"@web/test-runner-coverage-v8": "^0.1.2",
"chrome-launcher": "^0.13.3",
"puppeteer-core": "^5.0.0"
"@web/test-runner-core": "^0.8.0",
"@web/test-runner-coverage-v8": "^0.2.0",
"chrome-launcher": "^0.13.4",
"puppeteer-core": "^5.3.1"
},

@@ -50,0 +50,0 @@ "devDependencies": {

@@ -121,2 +121,6 @@ import * as puppeteerCore from 'puppeteer-core';

getBrowserUrl(sessionId: string) {
return this.getPage(sessionId).url();
}
async startDebugSession(sessionId: string, url: string) {

@@ -123,0 +127,0 @@ if (!this.debugBrowser) {

import { Page } from 'puppeteer-core';
import {
TestRunnerCoreConfig,
getBrowserPageNavigationError,
TestResultError,
CoverageMapData,
} from '@web/test-runner-core';
import { TestRunnerCoreConfig } from '@web/test-runner-core';
import { V8Coverage, v8ToIstanbul } from '@web/test-runner-coverage-v8';

@@ -17,4 +12,2 @@ import { SessionResult } from '@web/test-runner-core';

private nativeInstrumentationEnabledOnPage = false;
private testURL?: URL;
private navigations: URL[] = [];

@@ -31,15 +24,5 @@ constructor(

this.puppeteerPage = puppeteerPage;
// track browser navigations
puppeteerPage.on('request', e => {
if (e.isNavigationRequest()) {
this.navigations.push(new URL(e.url()));
}
});
}
async runSession(url: string, coverage: boolean) {
this.testURL = new URL(url);
this.navigations = [];
if (

@@ -62,13 +45,4 @@ coverage &&

async stopSession(): Promise<SessionResult> {
const errors: TestResultError[] = [];
let testCoverage: CoverageMapData | undefined;
const testCoverage = await this.collectTestCoverage(this.config, this.testFiles);
// check if the page was navigated, resulting in broken tests
const navigationError = getBrowserPageNavigationError(this.testURL!, this.navigations);
if (navigationError) {
errors.push(navigationError);
} else {
testCoverage = await this.collectTestCoverage(this.config, this.testFiles);
}
// navigate to an empty page to kill any running code on the page, stopping timers and

@@ -78,13 +52,17 @@ // breaking a potential endless reload loop

return { testCoverage, errors };
return { testCoverage };
}
private async collectTestCoverage(config: TestRunnerCoreConfig, testFiles: string[]) {
const coverageFromBrowser = await this.puppeteerPage.evaluate(
() => (window as any).__coverage__,
);
try {
const coverageFromBrowser = await this.puppeteerPage.evaluate(
() => (window as any).__coverage__,
);
if (coverageFromBrowser) {
// coverage was generated by JS, return that
return coverageFromBrowser;
if (coverageFromBrowser) {
// coverage was generated by JS, return that
return coverageFromBrowser;
}
} catch (error) {
// evaluate throws when the a test navigates in the browser
}

@@ -91,0 +69,0 @@

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