Socket
Socket
Sign inDemoInstall

@web/test-runner-core

Package Overview
Dependencies
Maintainers
5
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.2.3 to 0.2.4

6

CHANGELOG.md
# @web/test-runner-core
## 0.2.4
### Patch Changes
- 444ee32: support multiple browser launchers
## 0.2.3

@@ -4,0 +10,0 @@

3

dist/runner/createTestSessions.d.ts
import { TestSession } from '../test-session/TestSession';
export declare function createTestSessions(browserNames: string[], testFiles: string[]): TestSession[];
import { BrowserLauncher } from '../browser-launcher/BrowserLauncher';
export declare function createTestSessions(browserNamesPerLauncher: Map<BrowserLauncher, string[]>, testFiles: string[]): TestSession[];
//# sourceMappingURL=createTestSessions.d.ts.map

@@ -6,21 +6,21 @@ "use strict";

const TestSessionStatus_1 = require("../test-session/TestSessionStatus");
function createTestSessions(browserNames, testFiles) {
function createTestSessions(browserNamesPerLauncher, testFiles) {
const sessions = [];
// when running each test files in a separate tab, we group tests by file
for (const testFile of testFiles) {
const group = testFile;
const sessionsForFile = browserNames.map(browserName => ({
id: uuid_1.v4(),
testRun: -1,
group,
browserName,
status: TestSessionStatus_1.SESSION_STATUS.SCHEDULED,
testFile,
tests: [],
logs: [],
failedImports: [],
request404s: [],
}));
for (const session of sessionsForFile) {
sessions.push(session);
for (const [browserLauncher, browserNames] of browserNamesPerLauncher) {
for (const browserName of browserNames) {
const session = {
id: uuid_1.v4(),
testRun: -1,
browserName,
browserLauncher,
status: TestSessionStatus_1.SESSION_STATUS.SCHEDULED,
testFile,
tests: [],
logs: [],
failedImports: [],
request404s: [],
};
sessions.push(session);
}
}

@@ -27,0 +27,0 @@ }

@@ -28,3 +28,3 @@ import { TestRunnerConfig } from './TestRunnerConfig';

focusedTestFile: string | undefined;
private browsers;
private browserLaunchers;
private scheduler;

@@ -35,3 +35,3 @@ constructor(config: TestRunnerConfig, testFiles: string[]);

stop(): Promise<void>;
startDebugFocusedTestFile(): Promise<void> | undefined;
startDebugFocusedTestFile(): Promise<void[]>;
quit(error?: any): Promise<void>;

@@ -38,0 +38,0 @@ private onSessionFinished;

@@ -22,4 +22,4 @@ "use strict";

this.testFiles = testFiles;
this.browsers = Array.isArray(config.browsers) ? config.browsers : [config.browsers];
this.scheduler = new TestScheduler_1.TestScheduler(config, this.browsers, this.sessions);
this.browserLaunchers = Array.isArray(config.browsers) ? config.browsers : [config.browsers];
this.scheduler = new TestScheduler_1.TestScheduler(config, this.sessions);
this.sessions.on('session-status-updated', session => {

@@ -39,9 +39,16 @@ if (session.status === TestSessionStatus_1.SESSION_STATUS.FINISHED) {

this.startTime = Date.now();
const browserNamesPerLauncher = new Map();
this.browserNames = [];
for (const browser of this.browsers) {
const names = await browser.start(this.config);
for (const launcher of this.browserLaunchers) {
const names = await launcher.start(this.config);
if (!Array.isArray(names) || names.length === 0 || names.some(n => typeof n !== 'string')) {
throw new Error('Browser start must return an array of strings.');
}
this.browserNames.push(...names);
for (const name of names) {
if (this.browserNames.includes(name)) {
throw new Error(`Multiple browser launchers return the same browser name ${name}`);
}
this.browserNames.push(name);
}
browserNamesPerLauncher.set(launcher, names);
}

@@ -52,3 +59,3 @@ this.favoriteBrowser = (_a = this.browserNames.find(browserName => {

})) !== null && _a !== void 0 ? _a : this.browserNames[0];
const createdSessions = createTestSessions_1.createTestSessions(this.browserNames, this.testFiles);
const createdSessions = createTestSessions_1.createTestSessions(browserNamesPerLauncher, this.testFiles);
for (const session of createdSessions) {

@@ -79,6 +86,2 @@ this.sessions.add(session);

}
if (this.browsers.length > 1) {
// TODO: only pass sessions to browsers associated with it
throw new Error('Multiple browsers are not yet supported');
}
try {

@@ -101,3 +104,3 @@ this.testRun += 1;

});
for (const browser of this.browsers) {
for (const browser of this.browserLaunchers) {
browser.stop().catch(error => {

@@ -112,6 +115,9 @@ console.error(error);

}
const startPromises = [];
for (const session of this.sessions.forTestFile(this.focusedTestFile)) {
// TODO: select browser for session
return this.browsers[0].startDebugSession(session);
startPromises.push(session.browserLauncher.startDebugSession(session).catch(error => {
console.error(error);
}));
}
return Promise.all(startPromises);
}

@@ -129,6 +135,3 @@ async quit(error) {

try {
// TODO: find correct browser for session
for (const browser of this.browsers) {
browser.stopSession(session);
}
session.browserLauncher.stopSession(session);
this.scheduler.runScheduled(this.testRun).catch(error => {

@@ -135,0 +138,0 @@ this.quit(error);

import { TestSessionManager } from '../test-session/TestSessionManager';
import { TestSession } from '../test-session/TestSession';
import { BrowserLauncher } from '../browser-launcher/BrowserLauncher';
export interface TestSchedulerConfig {

@@ -12,5 +11,4 @@ concurrency?: number;

private config;
private browsers;
private sessions;
constructor(config: TestSchedulerConfig, browsers: BrowserLauncher[], sessions: TestSessionManager);
constructor(config: TestSchedulerConfig, sessions: TestSessionManager);
schedule(testRun: number, sessionsToSchedule: Iterable<TestSession>): Promise<void[]>;

@@ -17,0 +15,0 @@ runScheduled(testRun: number): Promise<void[]>;

@@ -6,5 +6,4 @@ "use strict";

class TestScheduler {
constructor(config, browsers, sessions) {
constructor(config, sessions) {
this.config = config;
this.browsers = browsers;
this.sessions = sessions;

@@ -45,3 +44,3 @@ }

// TODO: Select associated browser
await this.browsers[0].startSession(session);
await session.browserLauncher.startSession(session);
// when the browser started, wait for session to ping back on time

@@ -48,0 +47,0 @@ this.setSessionStartedTimeout(testRun, session.id);

import { CoverageMapData } from 'istanbul-lib-coverage';
import { TestSessionStatus } from './TestSessionStatus';
import { BrowserLauncher } from '../browser-launcher/BrowserLauncher';
export interface FailedImport {

@@ -21,2 +22,3 @@ file: string;

testRun: number;
browserLauncher: BrowserLauncher;
browserName: string;

@@ -23,0 +25,0 @@ testFile: string;

{
"name": "@web/test-runner-core",
"version": "0.2.3",
"version": "0.2.4",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

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