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

@tapjs/core

Package Overview
Dependencies
Maintainers
2
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tapjs/core - npm Package Compare versions

Comparing version 0.0.0-9 to 0.0.0-10

dist/cjs/message-from-error.d.ts

7

dist/cjs/base.d.ts

@@ -6,4 +6,4 @@ /**

*/
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import { Domain } from 'async-hook-domain';

@@ -46,2 +46,5 @@ import { AsyncResource } from 'async_hooks';

}
/**
* A number indicating an amount of milliseconds
*/
export type MILLISECONDS = number;

@@ -48,0 +51,0 @@ /**

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

const lists_js_1 = require("./lists.js");
const message_from_error_js_1 = require("./message-from-error.js");
/**

@@ -481,7 +482,19 @@ * Wrapper for the async-hook-domain that catches errors thrown during

}
const message = er.message;
const message = (0, message_from_error_js_1.messageFromError)(er);
if (!extra) {
extra = (0, extra_from_error_js_1.extraFromError)(er, extra);
}
extra.message = message;
this.parser.ok = false;
// if possible to handle it here, then return the info so that this
// Base subclass can do its thing
if (!ended &&
!this.results &&
/* c8 ignore start */
(this.parser.planEnd === -1 ||
this.parser.count < this.parser.planEnd)
/* c8 ignore stop */
) {
return extra;
}
// if we ended, we have to report it SOMEWHERE, unless we're

@@ -491,24 +504,14 @@ // already in the process of bailing out, in which case it's

// a plan exceeded error, or if we already have results.
if (ended ||
this.results ||
/* c8 ignore start */
(this.parser.planEnd !== -1 &&
this.parser.count >= this.parser.planEnd)
/* c8 ignore stop */
) {
this.debug('Base.threw, but finished', this.name, this.results, message);
const alreadyBailing = (this.results?.ok === false && this.bail) ||
this.parser.bailedOut ||
this.results?.bailout;
if (this.results)
this.results.ok = false;
if (this.parent) {
this.parent.threw(er, extra, true);
}
else if (alreadyBailing) {
// we are already bailing out, and this is the top level,
// just make our way hastily to the nearest exit.
return;
}
else if (!er.stack) {
this.debug('Base.threw, but finished', this.name, this.results, extra.message);
const alreadyBailing = (this.results?.ok === false && this.bail) ||
this.parser.bailedOut ||
this.results?.bailout;
if (this.results)
this.results.ok = false;
if (this.parent) {
this.parent.threw(er, extra, true);
}
else if (!alreadyBailing) {
// not already bailing out, so print the error as best we can
if (!er.stack) {
console.error(er);

@@ -520,7 +523,8 @@ }

/* c8 ignore stop */
console.error('%s: %s', name, message);
console.error('%s: %s', name, extra.message);
console.error((0, diags_js_1.diags)(extra));
}
}
return extra;
// we are already bailing out, and this is the top level,
// just make our way hastily to the nearest exit.
}

@@ -527,0 +531,0 @@ /**

@@ -135,2 +135,12 @@ "use strict";

}
// if the 'message' is a string, then we print it on the
// test point, so no need to repeat in the diags
if (typeof res.message === 'string')
delete res.message;
// worker: remove inline code
if (res.eval === true &&
typeof res.filename === 'string' &&
res.filename.includes('\n')) {
res.filename = '<inline code>';
}
return res;

@@ -137,0 +147,0 @@ };

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

/// <reference types="node" />
/// <reference types="node" resolution-mode="require"/>
/**

@@ -3,0 +3,0 @@ * grab some basic process stuff safely at startup

@@ -1,4 +0,4 @@

/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import { Base, TapBaseEvents } from './base.js';

@@ -8,2 +8,3 @@ import { WithExternalID } from '@tapjs/processinfo';

import { Readable, Stream, Writable } from 'node:stream';
import { Extra } from './index.js';
import { TestBaseOpts } from './test-base.js';

@@ -85,8 +86,9 @@ /**

endAll(): void;
main(cb: () => void): void | import("./index.js").Extra;
main(cb: () => void): void | Extra;
timeout(options?: {
expired?: string;
}): void;
threw(er: any, extra?: Extra): Extra | void | undefined;
static procName(cwd: string, command: string, args: string[]): string;
}
//# sourceMappingURL=spawn.d.ts.map

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

const node_path_1 = require("node:path");
const throw_to_parser_js_1 = require("./throw-to-parser.js");
const hasStdout = (p) => !!p.stdout;

@@ -194,2 +195,5 @@ /**

}
threw(er, extra) {
return (0, throw_to_parser_js_1.throwToParser)(this.parser, super.threw(er, extra));
}
static procName(cwd, command, args) {

@@ -196,0 +200,0 @@ return (command === process.execPath

@@ -1,3 +0,3 @@

/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import { Minipass } from 'minipass';

@@ -4,0 +4,0 @@ import { Base, BaseOpts, TapBaseEvents } from './base.js';

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

/// <reference types="node" />
/// <reference types="node" resolution-mode="require"/>
/**

@@ -3,0 +3,0 @@ * The root TAP object singleton, the `t` you get when you

@@ -1,4 +0,4 @@

/// <reference types="node" />
/// <reference types="node" />
import type { Test, TestOpts } from '@tapjs/test';
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import type { Test } from '@tapjs/test';
import { Minipass } from 'minipass';

@@ -294,3 +294,3 @@ import { Readable } from 'node:stream';

new (options: O): T;
}, extra: BaseOpts | TestOpts | TestBaseOpts | O | undefined, caller: (...a: any[]) => unknown): PromiseWithSubtest<T>;
}, extra: TestBaseOpts | O | undefined, caller: (...a: any[]) => unknown): PromiseWithSubtest<T>;
/**

@@ -322,4 +322,4 @@ * Method called when an unrecoverable error is encountered in a test.

*/
shouldSkipChild(extra: TestOpts | TestBaseOpts | BaseOpts): boolean;
shouldSkipChild<O extends BaseOpts>(extra: O | TestBaseOpts | BaseOpts): boolean;
}
//# sourceMappingURL=test-base.d.ts.map

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

// it'll always just be useless noise pointing back here.
if (!er || typeof er !== 'object') {
er = { error: er, at: null };
if (typeof er === 'string') {
er = { message: er, at: null };
}

@@ -987,3 +987,3 @@ if (this.name && !proxy) {

this.parser.ok = false;
super.threw(er, extra, proxy, ended);
const threwInfo = super.threw(er, extra, proxy, ended);
// Handle the failure here, but only if we (a) don't have

@@ -994,19 +994,17 @@ // results yet (indicating an end) and (b) are not currently

// failures)
if (!ended) {
const msg = typeof extra?.message === 'string'
? extra.message
: typeof er.message === 'string'
? er.message
: er.stack
? er.stack.split('\n')[0]
: typeof er.error === 'string'
? er.error
: '';
if (!ended && threwInfo) {
const msg = threwInfo.message;
extra ??= { at: null };
if (msg === '')
extra.at = null;
if (er.stack) {
if (this.parent && extra.test === this.name) {
// remove extraneous indicator if it's already nested
// in a TAP subtest
delete extra.test;
}
if (extra.error === msg) {
delete extra.error;
}
if (er.stack && typeof er.stack === 'string') {
// trim off the first line if it looks like the standard
// error `Name: message` line.
const f = `${er.name}: ${er.message}\n`;
const f = `${er.name || 'Error'}: ${er.message}\n`;
const st = er.stack.startsWith(f)

@@ -1019,2 +1017,4 @@ ? er.stack.substring(f.length)

}
if (!extra.at && !extra.stack)
extra.at = null;
this.fail(msg, extra);

@@ -1021,0 +1021,0 @@ if (this.ended || this.#pushedEnd) {

@@ -1,7 +0,8 @@

/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import { Base, TapBaseEvents } from './base.js';
import { TestBaseOpts } from './test-base.js';
import { Worker as NodeWorker } from 'node:worker_threads';
import { FinalResults } from 'tap-parser';
import { Extra } from './index.js';
import { TestBaseOpts } from './test-base.js';
/**

@@ -58,2 +59,3 @@ * Events emitted by {@link Worker} instances

main(cb: () => void): void;
threw(er: any, extra?: Extra): Extra | void | undefined;
timeout(options?: {

@@ -60,0 +62,0 @@ expired?: string;

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

const node_worker_threads_1 = require("node:worker_threads");
const throw_to_parser_js_1 = require("./throw-to-parser.js");
/**

@@ -71,2 +72,5 @@ * Class representing a TAP generating node worker thread

}
threw(er, extra) {
return (0, throw_to_parser_js_1.throwToParser)(this.parser, super.threw(er, extra));
}
#onworkerexit() {

@@ -73,0 +77,0 @@ this.#workerEnded = true;

@@ -6,4 +6,4 @@ /**

*/
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import { Domain } from 'async-hook-domain';

@@ -46,2 +46,5 @@ import { AsyncResource } from 'async_hooks';

}
/**
* A number indicating an amount of milliseconds
*/
export type MILLISECONDS = number;

@@ -48,0 +51,0 @@ /**

@@ -16,2 +16,3 @@ /**

import { Lists } from './lists.js';
import { messageFromError } from './message-from-error.js';
/**

@@ -477,7 +478,19 @@ * Wrapper for the async-hook-domain that catches errors thrown during

}
const message = er.message;
const message = messageFromError(er);
if (!extra) {
extra = extraFromError(er, extra);
}
extra.message = message;
this.parser.ok = false;
// if possible to handle it here, then return the info so that this
// Base subclass can do its thing
if (!ended &&
!this.results &&
/* c8 ignore start */
(this.parser.planEnd === -1 ||
this.parser.count < this.parser.planEnd)
/* c8 ignore stop */
) {
return extra;
}
// if we ended, we have to report it SOMEWHERE, unless we're

@@ -487,24 +500,14 @@ // already in the process of bailing out, in which case it's

// a plan exceeded error, or if we already have results.
if (ended ||
this.results ||
/* c8 ignore start */
(this.parser.planEnd !== -1 &&
this.parser.count >= this.parser.planEnd)
/* c8 ignore stop */
) {
this.debug('Base.threw, but finished', this.name, this.results, message);
const alreadyBailing = (this.results?.ok === false && this.bail) ||
this.parser.bailedOut ||
this.results?.bailout;
if (this.results)
this.results.ok = false;
if (this.parent) {
this.parent.threw(er, extra, true);
}
else if (alreadyBailing) {
// we are already bailing out, and this is the top level,
// just make our way hastily to the nearest exit.
return;
}
else if (!er.stack) {
this.debug('Base.threw, but finished', this.name, this.results, extra.message);
const alreadyBailing = (this.results?.ok === false && this.bail) ||
this.parser.bailedOut ||
this.results?.bailout;
if (this.results)
this.results.ok = false;
if (this.parent) {
this.parent.threw(er, extra, true);
}
else if (!alreadyBailing) {
// not already bailing out, so print the error as best we can
if (!er.stack) {
console.error(er);

@@ -516,7 +519,8 @@ }

/* c8 ignore stop */
console.error('%s: %s', name, message);
console.error('%s: %s', name, extra.message);
console.error(diags(extra));
}
}
return extra;
// we are already bailing out, and this is the top level,
// just make our way hastily to the nearest exit.
}

@@ -523,0 +527,0 @@ /**

@@ -109,2 +109,12 @@ import * as stack from '@tapjs/stack';

}
// if the 'message' is a string, then we print it on the
// test point, so no need to repeat in the diags
if (typeof res.message === 'string')
delete res.message;
// worker: remove inline code
if (res.eval === true &&
typeof res.filename === 'string' &&
res.filename.includes('\n')) {
res.filename = '<inline code>';
}
return res;

@@ -111,0 +121,0 @@ };

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

/// <reference types="node" />
/// <reference types="node" resolution-mode="require"/>
/**

@@ -3,0 +3,0 @@ * grab some basic process stuff safely at startup

@@ -1,4 +0,4 @@

/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import { Base, TapBaseEvents } from './base.js';

@@ -8,2 +8,3 @@ import { WithExternalID } from '@tapjs/processinfo';

import { Readable, Stream, Writable } from 'node:stream';
import { Extra } from './index.js';
import { TestBaseOpts } from './test-base.js';

@@ -85,8 +86,9 @@ /**

endAll(): void;
main(cb: () => void): void | import("./index.js").Extra;
main(cb: () => void): void | Extra;
timeout(options?: {
expired?: string;
}): void;
threw(er: any, extra?: Extra): Extra | void | undefined;
static procName(cwd: string, command: string, args: string[]): string;
}
//# sourceMappingURL=spawn.d.ts.map
import { Base } from './base.js';
import { ProcessInfo } from '@tapjs/processinfo';
import { basename } from 'node:path';
import { throwToParser } from './throw-to-parser.js';
const hasStdout = (p) => !!p.stdout;

@@ -190,2 +191,5 @@ /**

}
threw(er, extra) {
return throwToParser(this.parser, super.threw(er, extra));
}
static procName(cwd, command, args) {

@@ -192,0 +196,0 @@ return (command === process.execPath

@@ -1,3 +0,3 @@

/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import { Minipass } from 'minipass';

@@ -4,0 +4,0 @@ import { Base, BaseOpts, TapBaseEvents } from './base.js';

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

/// <reference types="node" />
/// <reference types="node" resolution-mode="require"/>
/**

@@ -3,0 +3,0 @@ * The root TAP object singleton, the `t` you get when you

@@ -1,4 +0,4 @@

/// <reference types="node" />
/// <reference types="node" />
import type { Test, TestOpts } from '@tapjs/test';
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import type { Test } from '@tapjs/test';
import { Minipass } from 'minipass';

@@ -294,3 +294,3 @@ import { Readable } from 'node:stream';

new (options: O): T;
}, extra: BaseOpts | TestOpts | TestBaseOpts | O | undefined, caller: (...a: any[]) => unknown): PromiseWithSubtest<T>;
}, extra: TestBaseOpts | O | undefined, caller: (...a: any[]) => unknown): PromiseWithSubtest<T>;
/**

@@ -322,4 +322,4 @@ * Method called when an unrecoverable error is encountered in a test.

*/
shouldSkipChild(extra: TestOpts | TestBaseOpts | BaseOpts): boolean;
shouldSkipChild<O extends BaseOpts>(extra: O | TestBaseOpts | BaseOpts): boolean;
}
//# sourceMappingURL=test-base.d.ts.map

@@ -941,4 +941,4 @@ import * as stack from '@tapjs/stack';

// it'll always just be useless noise pointing back here.
if (!er || typeof er !== 'object') {
er = { error: er, at: null };
if (typeof er === 'string') {
er = { message: er, at: null };
}

@@ -958,3 +958,3 @@ if (this.name && !proxy) {

this.parser.ok = false;
super.threw(er, extra, proxy, ended);
const threwInfo = super.threw(er, extra, proxy, ended);
// Handle the failure here, but only if we (a) don't have

@@ -965,19 +965,17 @@ // results yet (indicating an end) and (b) are not currently

// failures)
if (!ended) {
const msg = typeof extra?.message === 'string'
? extra.message
: typeof er.message === 'string'
? er.message
: er.stack
? er.stack.split('\n')[0]
: typeof er.error === 'string'
? er.error
: '';
if (!ended && threwInfo) {
const msg = threwInfo.message;
extra ??= { at: null };
if (msg === '')
extra.at = null;
if (er.stack) {
if (this.parent && extra.test === this.name) {
// remove extraneous indicator if it's already nested
// in a TAP subtest
delete extra.test;
}
if (extra.error === msg) {
delete extra.error;
}
if (er.stack && typeof er.stack === 'string') {
// trim off the first line if it looks like the standard
// error `Name: message` line.
const f = `${er.name}: ${er.message}\n`;
const f = `${er.name || 'Error'}: ${er.message}\n`;
const st = er.stack.startsWith(f)

@@ -990,2 +988,4 @@ ? er.stack.substring(f.length)

}
if (!extra.at && !extra.stack)
extra.at = null;
this.fail(msg, extra);

@@ -992,0 +992,0 @@ if (this.ended || this.#pushedEnd) {

@@ -1,7 +0,8 @@

/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import { Base, TapBaseEvents } from './base.js';
import { TestBaseOpts } from './test-base.js';
import { Worker as NodeWorker } from 'node:worker_threads';
import { FinalResults } from 'tap-parser';
import { Extra } from './index.js';
import { TestBaseOpts } from './test-base.js';
/**

@@ -58,2 +59,3 @@ * Events emitted by {@link Worker} instances

main(cb: () => void): void;
threw(er: any, extra?: Extra): Extra | void | undefined;
timeout(options?: {

@@ -60,0 +62,0 @@ expired?: string;

@@ -5,2 +5,3 @@ import { Base } from './base.js';

import { Worker as NodeWorker } from 'node:worker_threads';
import { throwToParser } from './throw-to-parser.js';
/**

@@ -68,2 +69,5 @@ * Class representing a TAP generating node worker thread

}
threw(er, extra) {
return throwToParser(this.parser, super.threw(er, extra));
}
#onworkerexit() {

@@ -70,0 +74,0 @@ this.#workerEnded = true;

{
"name": "@tapjs/core",
"version": "0.0.0-9",
"version": "0.0.0-10",
"description": "pluggable core of node-tap",
"author": "Isaac Z. Schlueter <i@izs.me> (https://blog.izs.me)",
"main": "./dist/cjs/index.js",
"module": "./dist/mjs/index.js",
"types": "./dist/mjs/index.d.ts",
"type": "module",
"exports": {

@@ -51,5 +49,5 @@ "./package.json": {

"dependencies": {
"@tapjs/processinfo": "^2.5.4",
"@tapjs/stack": "0.0.0-2",
"@tapjs/test": "0.0.0-9",
"@tapjs/processinfo": "^2.5.5",
"@tapjs/stack": "0.0.0-3",
"@tapjs/test": "0.0.0-10",
"async-hook-domain": "^4.0.1",

@@ -60,4 +58,4 @@ "is-actual-promise": "^1.0.0",

"signal-exit": "4.1",
"tap-parser": "15.0.0-0",
"tcompare": "6.0.1-1",
"tap-parser": "15.0.0-1",
"tcompare": "6.0.1-2",
"trivial-deferred": "^2.0.0"

@@ -64,0 +62,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

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

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