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.10.0 to 0.10.1

6

CHANGELOG.md
# @web/test-runner-core
## 0.10.1
### Patch Changes
- 9f1a8a56: normalize test framework path in stack trace
## 0.10.0

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

7

dist/server/plugins/api/parseBrowserErrors.d.ts
import { MapStackLocation } from '@web/browser-logs';
import { MapBrowserUrl } from '@web/browser-logs/src/parseStackTrace';
import { TestRunnerCoreConfig } from '../../../config/TestRunnerCoreConfig';
import { TestResultError, TestSession } from '../../../test-session/TestSession';
export declare function replaceErrorStack(error: TestResultError, mapStackLocation: MapStackLocation, rootDir: string): Promise<void>;
export declare function parseSessionErrors(config: TestRunnerCoreConfig, mapStackLocation: MapStackLocation, result: Partial<TestSession>): Promise<void>;
export declare function parseTestResults(config: TestRunnerCoreConfig, mapStackLocation: MapStackLocation, result: Partial<TestSession>): Promise<void>;
export declare function replaceErrorStack(error: TestResultError, mapBrowserUrl: MapBrowserUrl, mapStackLocation: MapStackLocation, rootDir: string): Promise<void>;
export declare function parseSessionErrors(config: TestRunnerCoreConfig, mapBrowserUrl: MapBrowserUrl, mapStackLocation: MapStackLocation, result: Partial<TestSession>): Promise<void>;
export declare function parseTestResults(config: TestRunnerCoreConfig, mapBrowserUrl: MapBrowserUrl, mapStackLocation: MapStackLocation, result: Partial<TestSession>): Promise<void>;
//# sourceMappingURL=parseBrowserErrors.d.ts.map

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

const async_1 = require("../../../utils/async");
async function replaceErrorStack(error, mapStackLocation, rootDir) {
async function replaceErrorStack(error, mapBrowserUrl, mapStackLocation, rootDir) {
try {
error.stack = await browser_logs_1.parseStackTrace(error.message, error.stack, {
mapBrowserUrl,
mapStackLocation,

@@ -20,3 +21,3 @@ browserRootDir: rootDir,

exports.replaceErrorStack = replaceErrorStack;
async function parseSessionErrors(config, mapStackLocation, result) {
async function parseSessionErrors(config, mapBrowserUrl, mapStackLocation, result) {
if (!result.errors) {

@@ -27,3 +28,3 @@ return;

if (err.stack) {
return replaceErrorStack(err, mapStackLocation, config.rootDir);
return replaceErrorStack(err, mapBrowserUrl, mapStackLocation, config.rootDir);
}

@@ -33,3 +34,3 @@ });

exports.parseSessionErrors = parseSessionErrors;
async function parseTestResults(config, mapStackLocation, result) {
async function parseTestResults(config, mapBrowserUrl, mapStackLocation, result) {
if (!result.testResults) {

@@ -42,3 +43,3 @@ return;

if ((_a = test.error) === null || _a === void 0 ? void 0 : _a.stack) {
await replaceErrorStack(test.error, mapStackLocation, config.rootDir);
await replaceErrorStack(test.error, mapBrowserUrl, mapStackLocation, config.rootDir);
}

@@ -45,0 +46,0 @@ });

import { MapStackLocation } from '@web/browser-logs';
import { MapBrowserUrl } from '@web/browser-logs/src/parseStackTrace';
import { TestRunnerCoreConfig } from '../../../config/TestRunnerCoreConfig';
import { TestSession } from '../../../test-session/TestSession';
export declare function parseBrowserLogs(config: TestRunnerCoreConfig, mapStackLocation: MapStackLocation, result: Partial<TestSession>): Promise<void>;
export declare function parseBrowserLogs(config: TestRunnerCoreConfig, mapBrowserUrl: MapBrowserUrl, mapStackLocation: MapStackLocation, result: Partial<TestSession>): Promise<void>;
//# sourceMappingURL=parseBrowserLogs.d.ts.map

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

const browser_logs_1 = require("@web/browser-logs");
const dev_server_core_1 = require("@web/dev-server-core");
const async_1 = require("../../../utils/async");

@@ -13,3 +12,3 @@ async function parseBrowserLog(browserLog, mapBrowserUrl, mapStackLocation, config) {

}
async function parseBrowserLogs(config, mapStackLocation, result) {
async function parseBrowserLogs(config, mapBrowserUrl, mapStackLocation, result) {
if (!result.logs) {

@@ -19,3 +18,2 @@ return;

const browserLogs = result.logs;
const mapBrowserUrl = (url) => dev_server_core_1.getRequestFilePath(url.href, config.rootDir);
const logsWithType = await async_1.mapAsync(browserLogs, b => parseBrowserLog(b, mapBrowserUrl, mapStackLocation, config));

@@ -22,0 +20,0 @@ const logs = [];

@@ -0,5 +1,6 @@

import { MapBrowserUrl } from '@web/browser-logs/src/parseStackTrace';
import { TestRunnerCoreConfig } from '../../../config/TestRunnerCoreConfig';
import { TestSession } from '../../../test-session/TestSession';
import { SourceMapFunction } from './createSourceMapFunction';
export declare function parseBrowserResult(config: TestRunnerCoreConfig, sourceMapFunction: SourceMapFunction, userAgent: string, result: Partial<TestSession>): Promise<Partial<TestSession>>;
export declare function parseBrowserResult(config: TestRunnerCoreConfig, mapBrowserUrl: MapBrowserUrl, sourceMapFunction: SourceMapFunction, userAgent: string, result: Partial<TestSession>): Promise<Partial<TestSession>>;
//# sourceMappingURL=parseBrowserResult.d.ts.map

@@ -12,8 +12,8 @@ "use strict";

}
async function parseBrowserResult(config, sourceMapFunction, userAgent, result) {
async function parseBrowserResult(config, mapBrowserUrl, sourceMapFunction, userAgent, result) {
const mapStackLocation = createMapStackLocation(sourceMapFunction, userAgent);
await Promise.all([
parseBrowserLogs_1.parseBrowserLogs(config, mapStackLocation, result),
parseBrowserErrors_1.parseSessionErrors(config, mapStackLocation, result),
parseBrowserErrors_1.parseTestResults(config, mapStackLocation, result),
parseBrowserLogs_1.parseBrowserLogs(config, mapBrowserUrl, mapStackLocation, result),
parseBrowserErrors_1.parseSessionErrors(config, mapBrowserUrl, mapStackLocation, result),
parseBrowserErrors_1.parseTestResults(config, mapBrowserUrl, mapStackLocation, result),
]);

@@ -20,0 +20,0 @@ return result;

@@ -19,2 +19,3 @@ import { Context, ServerStartParams } from '@web/dev-server-core';

private sourceMapFunction;
private mapBrowserUrl;
/** key: session id, value: browser url */

@@ -21,0 +22,0 @@ private testSessionUrls;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.testRunnerApiPlugin = void 0;
const dev_server_core_1 = require("@web/dev-server-core");
const constants_1 = require("../../../utils/constants");

@@ -8,2 +9,10 @@ const TestSessionStatus_1 = require("../../../test-session/TestSessionStatus");

const createSourceMapFunction_1 = require("./createSourceMapFunction");
function createMapBrowserUrl(rootDir) {
return function mapBrowserUrl(url) {
if (url.pathname.startsWith('/__web-test-runner__/test-framework')) {
return url.pathname.substring('/__web-test-runner__/test-framework'.length);
}
return dev_server_core_1.getRequestFilePath(url.href, rootDir);
};
}
class TestRunnerApiPlugin {

@@ -19,2 +28,3 @@ constructor(config, testRunner, sessions, plugins) {

this.plugins = plugins;
this.mapBrowserUrl = createMapBrowserUrl(config.rootDir);
this.sourceMapFunction = createSourceMapFunction_1.createSourceMapFunction(this.config.protocol, this.config.hostname, this.config.port);

@@ -98,3 +108,3 @@ this.testRunner.on('test-run-started', ({ testRun }) => {

}
const result = await parseBrowserResult_1.parseBrowserResult(this.config, this.sourceMapFunction, data.userAgent, message.result);
const result = await parseBrowserResult_1.parseBrowserResult(this.config, this.mapBrowserUrl, this.sourceMapFunction, data.userAgent, message.result);
this.sessions.updateStatus(Object.assign(Object.assign({}, session), result), TestSessionStatus_1.SESSION_STATUS.TEST_FINISHED);

@@ -101,0 +111,0 @@ }

{
"name": "@web/test-runner-core",
"version": "0.10.0",
"version": "0.10.1",
"publishConfig": {

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

import { MapStackLocation, parseStackTrace } from '@web/browser-logs';
import { MapBrowserUrl } from '@web/browser-logs/src/parseStackTrace';

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

error: TestResultError,
mapBrowserUrl: MapBrowserUrl,
mapStackLocation: MapStackLocation,

@@ -20,2 +22,3 @@ rootDir: string,

error.stack = await parseStackTrace(error.message, error.stack!, {
mapBrowserUrl,
mapStackLocation,

@@ -32,2 +35,3 @@ browserRootDir: rootDir,

config: TestRunnerCoreConfig,
mapBrowserUrl: MapBrowserUrl,
mapStackLocation: MapStackLocation,

@@ -42,3 +46,3 @@ result: Partial<TestSession>,

if (err.stack) {
return replaceErrorStack(err, mapStackLocation, config.rootDir);
return replaceErrorStack(err, mapBrowserUrl, mapStackLocation, config.rootDir);
}

@@ -50,2 +54,3 @@ });

config: TestRunnerCoreConfig,
mapBrowserUrl: MapBrowserUrl,
mapStackLocation: MapStackLocation,

@@ -61,3 +66,3 @@ result: Partial<TestSession>,

if (test.error?.stack) {
await replaceErrorStack(test.error, mapStackLocation, config.rootDir);
await replaceErrorStack(test.error, mapBrowserUrl, mapStackLocation, config.rootDir);
}

@@ -64,0 +69,0 @@ });

import { deserialize, MapStackLocation } from '@web/browser-logs';
import { MapBrowserUrl } from '@web/browser-logs/src/parseStackTrace';
import { getRequestFilePath } from '@web/dev-server-core';

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

config: TestRunnerCoreConfig,
mapBrowserUrl: MapBrowserUrl,
mapStackLocation: MapStackLocation,

@@ -38,4 +38,2 @@ result: Partial<TestSession>,

const browserLogs = (result.logs as any) as BrowserLog[];
const mapBrowserUrl = (url: URL) => getRequestFilePath(url.href, config.rootDir);
const logsWithType = await mapAsync(browserLogs, b =>

@@ -42,0 +40,0 @@ parseBrowserLog(b, mapBrowserUrl, mapStackLocation, config),

import { MapStackLocation, StackLocation } from '@web/browser-logs';
import { MapBrowserUrl } from '@web/browser-logs/src/parseStackTrace';

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

config: TestRunnerCoreConfig,
mapBrowserUrl: MapBrowserUrl,
sourceMapFunction: SourceMapFunction,

@@ -25,7 +27,7 @@ userAgent: string,

await Promise.all([
parseBrowserLogs(config, mapStackLocation, result),
parseSessionErrors(config, mapStackLocation, result),
parseTestResults(config, mapStackLocation, result),
parseBrowserLogs(config, mapBrowserUrl, mapStackLocation, result),
parseSessionErrors(config, mapBrowserUrl, mapStackLocation, result),
parseTestResults(config, mapBrowserUrl, mapStackLocation, result),
]);
return result;
}

@@ -1,2 +0,2 @@

import { Context, ServerStartParams, WebSocket } from '@web/dev-server-core';
import { Context, getRequestFilePath, ServerStartParams, WebSocket } from '@web/dev-server-core';

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

import { createSourceMapFunction, SourceMapFunction } from './createSourceMapFunction';
import { MapBrowserUrl } from '@web/browser-logs/src/parseStackTrace';

@@ -19,2 +20,11 @@ interface SessionMessage extends Record<string, unknown> {

function createMapBrowserUrl(rootDir: string) {
return function mapBrowserUrl(url: URL) {
if (url.pathname.startsWith('/__web-test-runner__/test-framework')) {
return url.pathname.substring('/__web-test-runner__/test-framework'.length);
}
return getRequestFilePath(url.href, rootDir);
};
}
class TestRunnerApiPlugin implements TestRunnerPlugin {

@@ -29,2 +39,3 @@ public name = 'test-runner-api';

private sourceMapFunction: SourceMapFunction;
private mapBrowserUrl: MapBrowserUrl;
/** key: session id, value: browser url */

@@ -43,2 +54,3 @@ private testSessionUrls = new Map<string, string>();

this.plugins = plugins;
this.mapBrowserUrl = createMapBrowserUrl(config.rootDir);
this.sourceMapFunction = createSourceMapFunction(

@@ -144,2 +156,3 @@ this.config.protocol,

this.config,
this.mapBrowserUrl,
this.sourceMapFunction,

@@ -146,0 +159,0 @@ data.userAgent,

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