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

poku

Package Overview
Dependencies
Maintainers
0
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

poku - npm Package Compare versions

Comparing version 2.4.1 to 2.4.2

lib/builders/assert.d.ts

2

lib/configs/poku.js

@@ -10,2 +10,2 @@ "use strict";

};
exports.VERSION = '2.4.1';
exports.VERSION = '2.4.2';

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

const node_assert_1 = __importDefault(require("assert"));
const assert_js_1 = require("../../services/assert.js");
const assert_js_1 = require("../../builders/assert.js");
exports.assert = (0, assert_js_1.createAssert)(node_assert_1.default);

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

(0, exit_js_1.exit)(code, configs === null || configs === void 0 ? void 0 : configs.quiet);
return;
}

@@ -48,0 +49,0 @@

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

const strict_1 = __importDefault(require("assert/strict"));
const assert_js_1 = require("../../services/assert.js");
const assert_js_1 = require("../../builders/assert.js");
exports.strict = (0, assert_js_1.createAssert)(strict_1.default);
import type { Code } from '../../@types/code.js';
export declare const exit: (code: Code, quiet?: boolean) => never;
export declare const exit: (code: Code, quiet?: boolean) => void;

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

const time_js_1 = require("../../parsers/time.js");
const node_assert_1 = require("assert");
const exit = (code, quiet) => {

@@ -53,14 +54,18 @@ const isPoku = poku_js_1.results.success > 0 || poku_js_1.results.fail > 0;

});
node_process_1.default.exit(code === 0 ? 0 : 1);
node_process_1.default.exitCode = code === 0 ? 0 : 1;
};
exports.exit = exit;
node_process_1.default.on('unhandledRejection', (reason) => {
console.error('unhandledRejection', reason);
node_process_1.default.exit(1);
node_process_1.default.on('unhandledRejection', (err) => {
if (!(err instanceof node_assert_1.AssertionError)) {
console.error('unhandledRejection', err);
}
node_process_1.default.exitCode = 1;
});
node_process_1.default.on('uncaughtException', (err) => {
console.error('uncaughtException', err);
node_process_1.default.exit(1);
if (!(err instanceof node_assert_1.AssertionError)) {
console.error('uncaughtException', err);
}
node_process_1.default.exitCode = 1;
});
import type { ProcessAssertionOptions } from '../@types/assert.js';
import type assert from 'node:assert';
import type { AssertPredicate } from 'node:assert';
export declare const processAssert: (cb: () => void | Promise<void>, options: ProcessAssertionOptions) => Promise<void>;
export declare const createAssert: (nodeAssert: typeof assert) => ((value: unknown, message?: ProcessAssertionOptions["message"]) => void) & {
ok: (value: unknown, message?: ProcessAssertionOptions["message"]) => void;
equal: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
deepEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
strictEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
deepStrictEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
doesNotMatch: (value: string, regExp: RegExp, message?: ProcessAssertionOptions["message"]) => void;
doesNotReject: {
(block: (() => Promise<unknown>) | Promise<unknown>, message?: ProcessAssertionOptions["message"]): Promise<void>;
(block: (() => Promise<unknown>) | Promise<unknown>, error: AssertPredicate, message?: ProcessAssertionOptions["message"]): Promise<void>;
};
throws: {
(block: () => unknown, message?: ProcessAssertionOptions["message"]): void;
(block: () => unknown, error: AssertPredicate, message?: ProcessAssertionOptions["message"]): void;
};
doesNotThrow: {
(block: () => unknown, message?: string | ProcessAssertionOptions["message"]): void;
(block: () => unknown, error: AssertPredicate, message?: ProcessAssertionOptions["message"]): void;
};
notEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
notDeepEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
notStrictEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
notDeepStrictEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
match: (value: string, regExp: RegExp, message?: ProcessAssertionOptions["message"]) => void;
ifError: (value: unknown, message?: ProcessAssertionOptions["message"]) => void;
fail: (message?: ProcessAssertionOptions["message"]) => never;
rejects: {
(block: (() => Promise<unknown>) | Promise<unknown>, message?: ProcessAssertionOptions["message"]): Promise<void>;
(block: (() => Promise<unknown>) | Promise<unknown>, error: AssertPredicate, message?: ProcessAssertionOptions["message"]): Promise<void>;
};
};
export declare const processAssert: (cb: () => void, options: ProcessAssertionOptions) => void, processAsyncAssert: (cb: () => Promise<void>, options: ProcessAssertionOptions) => Promise<void>;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createAssert = exports.processAssert = void 0;
exports.processAsyncAssert = exports.processAssert = void 0;
const node_assert_1 = require("assert");
const node_process_1 = require("process");
const node_process_1 = __importStar(require("process"));
const node_path_1 = __importDefault(require("path"));
const find_file_from_stack_js_1 = require("../parsers/find-file-from-stack.js");
const assert_js_1 = require("../parsers/assert.js");
const get_runtime_js_1 = require("../parsers/get-runtime.js");
const indentation_js_1 = require("../configs/indentation.js");

@@ -18,18 +41,14 @@ const format_js_1 = require("./format.js");

const regexFile = /file:(\/\/)?/;
const processAssert = async (cb, options) => {
const assertProcessor = () => {
const isPoku = typeof (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE) === 'string' && (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE.length) > 0;
const FILE = node_process_1.env.FILE;
let preIdentation = '';
if (indentation_js_1.indentation.hasDescribe) {
preIdentation += ' ';
}
if (indentation_js_1.indentation.hasItOrTest) {
preIdentation += ' ';
}
try {
const cbResult = cb();
if (cbResult instanceof Promise) {
await cbResult;
}
const handleSuccess = (options) => {
if (typeof options.message === 'string') {
if (indentation_js_1.indentation.hasDescribe) {
preIdentation += ' ';
}
if (indentation_js_1.indentation.hasItOrTest) {
preIdentation += ' ';
}
const message = isPoku && !indentation_js_1.indentation.hasDescribe && !indentation_js_1.indentation.hasItOrTest

@@ -40,4 +59,6 @@ ? `${preIdentation}${(0, format_js_1.format)(`${(0, format_js_1.format)(`✔ ${options.message}`).bold()} ${(0, format_js_1.format)(`› ${FILE}`).success().dim()}`).success()}`

}
}
catch (error) {
preIdentation = '';
};
const handleError = (error, options) => {
node_process_1.default.exitCode = 1;
if (error instanceof node_assert_1.AssertionError) {

@@ -47,2 +68,8 @@ const { code, actual, expected, operator } = error;

const file = node_path_1.default.relative(node_path_1.default.resolve(cwd), absolutePath);
if (indentation_js_1.indentation.hasDescribe) {
preIdentation += ' ';
}
if (indentation_js_1.indentation.hasItOrTest) {
preIdentation += ' ';
}
let message = '';

@@ -79,2 +106,3 @@ if (typeof options.message === 'string') {

}
preIdentation = '';
}

@@ -85,186 +113,29 @@ if (options.throw) {

}
(0, node_process_1.exit)(1);
if (isPoku) {
throw error;
}
}
throw error;
}
};
exports.processAssert = processAssert;
const createAssert = (nodeAssert) => {
const ok = (value, message) => {
(0, exports.processAssert)(() => {
nodeAssert.ok(value);
}, { message });
};
const equal = (actual, expected, message) => {
(0, exports.processAssert)(() => {
nodeAssert.equal(actual, expected);
}, { message });
};
const deepEqual = (actual, expected, message) => {
(0, exports.processAssert)(() => nodeAssert.deepEqual(actual, expected), { message });
};
const strictEqual = (actual, expected, message) => {
(0, exports.processAssert)(() => nodeAssert.strictEqual(actual, expected), { message });
};
const deepStrictEqual = (actual, expected, message) => {
(0, exports.processAssert)(() => nodeAssert.deepStrictEqual(actual, expected), {
message,
});
};
const notEqual = (actual, expected, message) => {
(0, exports.processAssert)(() => nodeAssert.notEqual(actual, expected), {
message,
});
};
const notDeepEqual = (actual, expected, message) => {
(0, exports.processAssert)(() => nodeAssert.notDeepEqual(actual, expected), { message });
};
const notStrictEqual = (actual, expected, message) => {
(0, exports.processAssert)(() => nodeAssert.notStrictEqual(actual, expected), {
message,
});
};
const notDeepStrictEqual = (actual, expected, message) => {
(0, exports.processAssert)(() => nodeAssert.notDeepStrictEqual(actual, expected), {
message,
});
};
const ifError = (value, message) => {
(0, exports.processAssert)(() => {
nodeAssert.ifError(value);
}, {
message,
defaultMessage: 'Expected no error, but received an error',
hideDiff: true,
throw: true,
});
};
const fail = (message) => {
(0, exports.processAssert)(() => {
nodeAssert.fail(message);
}, {
message,
defaultMessage: 'Test failed intentionally',
hideDiff: true,
});
process.exit(1);
};
function doesNotThrow(block, errorOrMessage, message) {
(0, exports.processAssert)(() => {
if (typeof errorOrMessage === 'function' ||
errorOrMessage instanceof RegExp ||
typeof errorOrMessage === 'object') {
nodeAssert.doesNotThrow(block, errorOrMessage, message);
}
else {
const msg = typeof errorOrMessage === 'string' ? errorOrMessage : message;
nodeAssert.doesNotThrow(block, msg);
}
}, {
message: typeof errorOrMessage === 'string' ? errorOrMessage : message,
defaultMessage: 'Expected function not to throw',
hideDiff: true,
throw: true,
});
}
function throws(block, errorOrMessage, message) {
if (typeof errorOrMessage === 'function' ||
errorOrMessage instanceof RegExp ||
typeof errorOrMessage === 'object') {
(0, exports.processAssert)(() => nodeAssert.throws(block, errorOrMessage), {
message,
defaultMessage: 'Expected function to throw',
hideDiff: true,
});
const processAssert = (cb, options) => {
try {
cb();
handleSuccess(options);
}
else {
const msg = typeof errorOrMessage !== 'undefined' ? errorOrMessage : message;
(0, exports.processAssert)(() => nodeAssert.throws(block, message), {
message: msg,
defaultMessage: 'Expected function to throw',
hideDiff: true,
});
catch (error) {
handleError(error, options);
}
}
async function rejects(block, errorOrMessage, message) {
await (0, exports.processAssert)(async () => {
if (typeof errorOrMessage === 'function' ||
errorOrMessage instanceof RegExp ||
typeof errorOrMessage === 'object') {
await nodeAssert.rejects(block, errorOrMessage, message);
}
else {
const msg = typeof errorOrMessage === 'string' ? errorOrMessage : message;
await nodeAssert.rejects(block, msg);
}
}, {
message: typeof errorOrMessage === 'string' ? errorOrMessage : message,
defaultMessage: 'Expected promise to be rejected with specified error',
hideDiff: true,
throw: true,
});
}
async function doesNotReject(block, errorOrMessage, message) {
await (0, exports.processAssert)(async () => {
if (typeof errorOrMessage === 'function' ||
errorOrMessage instanceof RegExp ||
typeof errorOrMessage === 'object') {
await nodeAssert.doesNotReject(block, errorOrMessage, message);
}
else {
await nodeAssert.doesNotReject(block, message);
}
}, {
message: typeof errorOrMessage === 'string' ? errorOrMessage : message,
defaultMessage: 'Got unwanted rejection',
hideDiff: true,
throw: true,
});
}
const match = (value, regExp, message) => {
if (typeof get_runtime_js_1.nodeVersion === 'number' && get_runtime_js_1.nodeVersion < 12) {
throw new Error('match is available from Node.js 12 or higher');
}
(0, exports.processAssert)(() => nodeAssert === null || nodeAssert === void 0 ? void 0 : nodeAssert.match(value, regExp), {
message,
actual: 'Value',
expected: 'RegExp',
defaultMessage: 'Value should match regExp',
});
};
const doesNotMatch = (value, regExp, message) => {
if (typeof get_runtime_js_1.nodeVersion === 'number' && get_runtime_js_1.nodeVersion < 12) {
throw new Error('doesNotMatch is available from Node.js 12 or higher');
const processAsyncAssert = async (cb, options) => {
try {
await cb();
handleSuccess(options);
}
(0, exports.processAssert)(() => nodeAssert.doesNotMatch(value, regExp), {
message,
actual: 'Value',
expected: 'RegExp',
defaultMessage: 'Value should not match regExp',
});
catch (error) {
handleError(error, options);
}
};
const assert = Object.assign((value, message) => ok(value, message), {
ok,
equal,
deepEqual,
strictEqual,
deepStrictEqual,
doesNotMatch,
doesNotReject,
throws,
doesNotThrow,
notEqual,
notDeepEqual,
notStrictEqual,
notDeepStrictEqual,
match,
ifError,
fail,
rejects,
});
return assert;
return { processAssert, processAsyncAssert };
};
exports.createAssert = createAssert;
_a = assertProcessor(), exports.processAssert = _a.processAssert, exports.processAsyncAssert = _a.processAsyncAssert;

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

hr: () => {
const line = '⎯'.repeat(node_process_1.stdout.columns - 10 || 40);
const line = '─'.repeat(node_process_1.stdout.columns - 10 || 40);
exports.Write.log(`\n\x1b[2m\x1b[90m${line}\x1b[0m\n`);
},
};
{
"name": "poku",
"version": "2.4.1",
"version": "2.4.2",
"description": "🐷 Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.",

@@ -5,0 +5,0 @@ "main": "./lib/modules/index.js",

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