Socket
Socket
Sign inDemoInstall

@web/test-runner-core

Package Overview
Dependencies
Maintainers
7
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.9.3 to 0.10.0

dist/server/plugins/api/createSourceMapFunction.d.ts

1

browser/session.d.ts

@@ -13,2 +13,3 @@ import { TestSession, TestResultError, TestSuiteResult, TestResult } from '../dist/index';

export interface FullBrowserSessionResult extends BrowserSessionResult {
userAgent: string;
logs: string[];

@@ -15,0 +16,0 @@ }

@@ -46,3 +46,4 @@ /* eslint-env browser, es2020 */

await sessionFailed({
message: 'Failed to fetch test config',
name: err ? err.name : undefined,
message: `Failed to fetch test config: ${err ? err.message : 'Unknown error'}`,
stack: err ? err.stack : undefined,

@@ -56,2 +57,3 @@ });

return sessionFinished({
userAgent: window.navigator.userAgent,
passed: false,

@@ -61,2 +63,3 @@ errors: [

{
name: error.name,
message: error.message,

@@ -98,3 +101,9 @@ stack: error.stack,

await sendMessage({ type: 'wtr-session-finished', sessionId, testFile, result: fullResult });
await sendMessage({
type: 'wtr-session-finished',
userAgent: window.navigator.userAgent,
sessionId,
testFile,
result: fullResult,
});
}
# @web/test-runner-core
## 0.10.0
### Minor Changes
- 1dd7cd0e: improve serialization of stack traces cross-browser
this adds two breaking changes, which should not affect most users:
- removed `userAgent` field from `TestSession`
- test reporter `reportTestFileResults` is no longer async
- a7d74fdc: drop support for node v10 and v11
### Patch Changes
- Updated dependencies [1dd7cd0e]
- Updated dependencies [1dd7cd0e]
- @web/dev-server-core@0.3.3
- @web/browser-logs@0.2.0
## 0.9.3

@@ -4,0 +24,0 @@

1

dist/cli/TestRunnerCli.d.ts

@@ -32,3 +32,2 @@ import { TestRunnerCoreConfig } from '../config/TestRunnerCoreConfig';

private reportTestResult;
private getTestResultReports;
private reportTestProgress;

@@ -35,0 +34,0 @@ private reportSyntaxErrors;

@@ -158,5 +158,7 @@ "use strict";

}
const clearTerminal = testRun !== 0 && this.config.watch;
this.reportTestProgress(false, clearTerminal);
if (testRun !== 0 && this.config.watch) {
this.terminal.clear();
}
this.reportTestResults();
this.reportTestProgress(false);
});

@@ -210,3 +212,4 @@ this.runner.on('test-run-finished', ({ testRun, testCoverage }) => {

}
async reportTestResult(testFile, forceReport = false) {
reportTestResult(testFile, forceReport = false) {
var _a;
const testRun = this.runner.testRun;

@@ -230,21 +233,6 @@ const sessionsForTestFile = Array.from(this.sessions.forTestFile(testFile));

const bufferedLogger = new BufferedLogger_1.BufferedLogger(this.logger);
const reportsPromises = this.getTestResultReports(bufferedLogger, testFile, testRun);
this.pendingReportPromises.push(...reportsPromises);
await Promise.all(reportsPromises);
for (const prom of reportsPromises) {
this.pendingReportPromises.splice(this.pendingReportPromises.indexOf(prom), 1);
}
// all the logs from the reportered were buffered, if they finished before a new test run
// actually log them to the terminal here
if (this.runner.testRun === testRun) {
bufferedLogger.logBufferedMessages();
}
}
getTestResultReports(logger, testFile, testRun) {
var _a;
const reportPromises = [];
for (const reporter of this.config.reporters) {
const sessionsForTestFile = Array.from(this.sessions.forTestFile(testFile));
const maybeReportPromise = (_a = reporter.reportTestFileResults) === null || _a === void 0 ? void 0 : _a.call(reporter, {
logger,
(_a = reporter.reportTestFileResults) === null || _a === void 0 ? void 0 : _a.call(reporter, {
logger: bufferedLogger,
sessionsForTestFile,

@@ -254,7 +242,10 @@ testFile,

});
reportPromises.push(Promise.resolve(maybeReportPromise).catch(err => console.error(err)));
}
return reportPromises;
// all the logs from the reportered were buffered, if they finished before a new test run
// actually log them to the terminal here
if (this.runner.testRun === testRun) {
bufferedLogger.logBufferedMessages();
}
}
reportTestProgress(final = false, clearTerminal = false) {
reportTestProgress(final = false) {
var _a;

@@ -291,5 +282,2 @@ if (this.config.manual) {

}
if (clearTerminal) {
this.terminal.clear();
}
if (logStatic) {

@@ -386,3 +374,2 @@ this.terminal.logStatic(reports);

this.reportTestProgress(true);
await Promise.all(this.pendingReportPromises);
this.terminal.stop();

@@ -389,0 +376,0 @@ this.runner.stop();

@@ -45,3 +45,3 @@ import { TestSession } from '../test-session/TestSession';

export interface Reporter {
reportTestFileResults?(args: ReportTestResultsArgs): void | Promise<void>;
reportTestFileResults?(args: ReportTestResultsArgs): void;
getTestProgress?(args: GetTestProgressArgs): string | string[];

@@ -48,0 +48,0 @@ onTestRunStarted?(args: TestRunStartedArgs): void;

@@ -40,3 +40,3 @@ "use strict";

this.scheduler = new TestScheduler_1.TestScheduler(config, this.sessions, browsers);
this.server = new TestRunnerServer_1.TestRunnerServer(this.config, this.sessions, this.testFiles, sessions => {
this.server = new TestRunnerServer_1.TestRunnerServer(this.config, this, this.sessions, this.testFiles, sessions => {
this.runTests(sessions);

@@ -43,0 +43,0 @@ });

@@ -134,3 +134,4 @@ "use strict";

const isTestRunnerHtml = context.path === '/';
if (!isTestRunnerHtml && !testFiles.includes(dev_server_core_1.getRequestFilePath(context, config.rootDir))) {
if (!isTestRunnerHtml &&
!testFiles.includes(dev_server_core_1.getRequestFilePath(context.url, config.rootDir))) {
return;

@@ -137,0 +138,0 @@ }

import { RunSessions } from './middleware/watchFilesMiddleware';
import { TestRunnerCoreConfig } from '../config/TestRunnerCoreConfig';
import { TestSessionManager } from '../test-session/TestSessionManager';
import { TestRunner } from '../runner/TestRunner';
export declare class TestRunnerServer {
private devServer;
private fileWatcher;
constructor(config: TestRunnerCoreConfig, sessions: TestSessionManager, testFiles: string[], runSessions: RunSessions);
constructor(config: TestRunnerCoreConfig, testRunner: TestRunner, sessions: TestSessionManager, testFiles: string[], runSessions: RunSessions);
start(): Promise<void>;

@@ -9,0 +10,0 @@ stop(): Promise<void>;

@@ -13,3 +13,3 @@ "use strict";

const serveTestFrameworkPlugin_1 = require("./plugins/serveTestFrameworkPlugin");
const testRunnerApiPlugin_1 = require("./plugins/testRunnerApiPlugin");
const testRunnerApiPlugin_1 = require("./plugins/api/testRunnerApiPlugin");
const CACHED_PATTERNS = [

@@ -23,3 +23,3 @@ 'node_modules/@web/test-runner-',

class TestRunnerServer {
constructor(config, sessions, testFiles, runSessions) {
constructor(config, testRunner, sessions, testFiles, runSessions) {
this.fileWatcher = chokidar_1.default.watch([]);

@@ -42,3 +42,3 @@ const { plugins = [], testFramework, rootDir } = config;

plugins: [
testRunnerApiPlugin_1.testRunnerApiPlugin(config, plugins, sessions),
testRunnerApiPlugin_1.testRunnerApiPlugin(config, testRunner, sessions, plugins),
serveTestRunnerHtmlPlugin_1.serveTestRunnerHtmlPlugin(config, testFiles, sessions, testFrameworkImport),

@@ -45,0 +45,0 @@ testFrameworkPlugin,

@@ -6,2 +6,3 @@ import { CoverageMapData } from 'istanbul-lib-coverage';

message: string;
name?: string;
stack?: string;

@@ -33,4 +34,3 @@ expected?: string;

testCoverage?: CoverageMapData;
userAgent?: string;
}
//# sourceMappingURL=TestSession.d.ts.map

@@ -5,2 +5,12 @@ /**

export declare function withTimeout<T>(promise: Promise<T> | void, message: string, timeout: number): Promise<T>;
/**
* Iterates iterable, executes each function in parallel and awaits
* all function return values
*/
export declare function forEachAsync<T>(it: Iterable<T>, fn: (t: T) => void | Promise<void>): Promise<void>;
/**
* Iterates iterable, executes each function in parallel and awaits
* all function return values returning the awaited result
*/
export declare function mapAsync<T, R>(it: Iterable<T>, fn: (t: T) => R | Promise<R>): Promise<R[]>;
//# sourceMappingURL=async.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withTimeout = void 0;
exports.mapAsync = exports.forEachAsync = exports.withTimeout = void 0;
/**

@@ -29,2 +29,26 @@ * Wraps a Promise with a timeout, rejecing the promise with the timeout.

exports.withTimeout = withTimeout;
/**
* Iterates iterable, executes each function in parallel and awaits
* all function return values
*/
async function forEachAsync(it, fn) {
const result = [];
for (const e of it) {
result.push(fn(e));
}
await Promise.all(result);
}
exports.forEachAsync = forEachAsync;
/**
* Iterates iterable, executes each function in parallel and awaits
* all function return values returning the awaited result
*/
function mapAsync(it, fn) {
const result = [];
for (const e of it) {
result.push(fn(e));
}
return Promise.all(result);
}
exports.mapAsync = mapAsync;
//# sourceMappingURL=async.js.map
{
"name": "@web/test-runner-core",
"version": "0.9.3",
"version": "0.10.0",
"publishConfig": {

@@ -30,3 +30,3 @@ "access": "public"

"engines": {
"node": ">=10.0.0"
"node": ">=12.0.0"
},

@@ -55,4 +55,4 @@ "scripts": {

"@babel/code-frame": "^7.12.11",
"@web/browser-logs": "^0.1.6",
"@web/dev-server-core": "^0.3.1",
"@web/browser-logs": "^0.2.0",
"@web/dev-server-core": "^0.3.3",
"chalk": "^4.1.0",

@@ -74,2 +74,3 @@ "cli-cursor": "^3.1.0",

"@types/co-body": "^5.1.0",
"@types/convert-source-map": "^1.5.1",
"@types/debounce": "^1.2.0",

@@ -76,0 +77,0 @@ "@types/istanbul-lib-coverage": "^2.0.3",

@@ -187,5 +187,7 @@ import { codeFrameColumns } from '@babel/code-frame';

const clearTerminal = testRun !== 0 && this.config.watch;
this.reportTestProgress(false, clearTerminal);
if (testRun !== 0 && this.config.watch) {
this.terminal.clear();
}
this.reportTestResults();
this.reportTestProgress(false);
});

@@ -247,3 +249,3 @@

private async reportTestResult(testFile: string, forceReport = false) {
private reportTestResult(testFile: string, forceReport = false) {
const testRun = this.runner.testRun;

@@ -270,24 +272,6 @@ const sessionsForTestFile = Array.from(this.sessions.forTestFile(testFile));

const bufferedLogger = new BufferedLogger(this.logger);
const reportsPromises = this.getTestResultReports(bufferedLogger, testFile, testRun);
this.pendingReportPromises.push(...reportsPromises);
await Promise.all(reportsPromises);
for (const prom of reportsPromises) {
this.pendingReportPromises.splice(this.pendingReportPromises.indexOf(prom), 1);
}
// all the logs from the reportered were buffered, if they finished before a new test run
// actually log them to the terminal here
if (this.runner.testRun === testRun) {
bufferedLogger.logBufferedMessages();
}
}
private getTestResultReports(logger: Logger, testFile: string, testRun: number) {
const reportPromises: Promise<void>[] = [];
for (const reporter of this.config.reporters) {
const sessionsForTestFile = Array.from(this.sessions.forTestFile(testFile));
const maybeReportPromise = reporter.reportTestFileResults?.({
logger,
reporter.reportTestFileResults?.({
logger: bufferedLogger,
sessionsForTestFile,

@@ -297,9 +281,12 @@ testFile,

});
reportPromises.push(Promise.resolve(maybeReportPromise).catch(err => console.error(err)));
}
return reportPromises;
// all the logs from the reportered were buffered, if they finished before a new test run
// actually log them to the terminal here
if (this.runner.testRun === testRun) {
bufferedLogger.logBufferedMessages();
}
}
private reportTestProgress(final = false, clearTerminal = false) {
private reportTestProgress(final = false) {
if (this.config.manual) {

@@ -352,5 +339,2 @@ return;

if (clearTerminal) {
this.terminal.clear();
}
if (logStatic) {

@@ -467,3 +451,2 @@ this.terminal.logStatic(reports);

this.reportTestProgress(true);
await Promise.all(this.pendingReportPromises);
this.terminal.stop();

@@ -470,0 +453,0 @@ this.runner.stop();

@@ -51,3 +51,3 @@ import { TestSession } from '../test-session/TestSession';

export interface Reporter {
reportTestFileResults?(args: ReportTestResultsArgs): void | Promise<void>;
reportTestFileResults?(args: ReportTestResultsArgs): void;
getTestProgress?(args: GetTestProgressArgs): string | string[];

@@ -54,0 +54,0 @@ onTestRunStarted?(args: TestRunStartedArgs): void;

@@ -70,5 +70,11 @@ import { TestRunnerCoreConfig } from '../config/TestRunnerCoreConfig';

this.scheduler = new TestScheduler(config, this.sessions, browsers);
this.server = new TestRunnerServer(this.config, this.sessions, this.testFiles, sessions => {
this.runTests(sessions);
});
this.server = new TestRunnerServer(
this.config,
this,
this.sessions,
this.testFiles,
sessions => {
this.runTests(sessions);
},
);
this.sessions.on('session-status-updated', session => {

@@ -75,0 +81,0 @@ if (session.status === SESSION_STATUS.FINISHED) {

@@ -169,3 +169,6 @@ import { Context, getRequestFilePath } from '@web/dev-server-core';

const isTestRunnerHtml = context.path === '/';
if (!isTestRunnerHtml && !testFiles.includes(getRequestFilePath(context, config.rootDir))) {
if (
!isTestRunnerHtml &&
!testFiles.includes(getRequestFilePath(context.url, config.rootDir))
) {
return;

@@ -172,0 +175,0 @@ }

@@ -8,5 +8,6 @@ import { DevServer, Plugin } from '@web/dev-server-core';

import { serveTestFrameworkPlugin } from './plugins/serveTestFrameworkPlugin';
import { testRunnerApiPlugin } from './plugins/testRunnerApiPlugin';
import { testRunnerApiPlugin } from './plugins/api/testRunnerApiPlugin';
import { TestRunnerCoreConfig } from '../config/TestRunnerCoreConfig';
import { TestSessionManager } from '../test-session/TestSessionManager';
import { TestRunner } from '../runner/TestRunner';

@@ -27,2 +28,3 @@ const CACHED_PATTERNS = [

config: TestRunnerCoreConfig,
testRunner: TestRunner,
sessions: TestSessionManager,

@@ -51,3 +53,3 @@ testFiles: string[],

plugins: [
testRunnerApiPlugin(config, plugins, sessions),
testRunnerApiPlugin(config, testRunner, sessions, plugins),
serveTestRunnerHtmlPlugin(config, testFiles, sessions, testFrameworkImport),

@@ -54,0 +56,0 @@ testFrameworkPlugin,

@@ -7,2 +7,3 @@ import { CoverageMapData } from 'istanbul-lib-coverage';

message: string;
name?: string;
stack?: string;

@@ -37,3 +38,2 @@ expected?: string;

testCoverage?: CoverageMapData;
userAgent?: string;
}

@@ -31,1 +31,28 @@ /**

}
/**
* Iterates iterable, executes each function in parallel and awaits
* all function return values
*/
export async function forEachAsync<T>(
it: Iterable<T>,
fn: (t: T) => void | Promise<void>,
): Promise<void> {
const result: (void | Promise<void>)[] = [];
for (const e of it) {
result.push(fn(e));
}
await Promise.all(result);
}
/**
* Iterates iterable, executes each function in parallel and awaits
* all function return values returning the awaited result
*/
export function mapAsync<T, R>(it: Iterable<T>, fn: (t: T) => R | Promise<R>): Promise<R[]> {
const result: (R | Promise<R>)[] = [];
for (const e of it) {
result.push(fn(e));
}
return Promise.all(result);
}

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

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