Comparing version 1.6.1 to 1.7.0
@@ -0,1 +1,18 @@ | ||
export declare const backgroundColor: { | ||
readonly white: 7; | ||
readonly black: 40; | ||
readonly grey: 100; | ||
readonly red: 41; | ||
readonly green: 42; | ||
readonly yellow: 43; | ||
readonly blue: 44; | ||
readonly magenta: 45; | ||
readonly cyan: 46; | ||
readonly brightRed: 101; | ||
readonly brightGreen: 102; | ||
readonly brightYellow: 103; | ||
readonly brightBlue: 104; | ||
readonly brightMagenta: 105; | ||
readonly brightCyan: 106; | ||
}; | ||
export declare const format: { | ||
@@ -2,0 +19,0 @@ counter: (current: number, total: number, pad?: string) => string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getLargestStringLength = exports.format = void 0; | ||
exports.getLargestStringLength = exports.format = exports.backgroundColor = void 0; | ||
const pad_js_1 = require("./pad.js"); | ||
exports.backgroundColor = { | ||
white: 7, | ||
black: 40, | ||
grey: 100, | ||
red: 41, | ||
green: 42, | ||
yellow: 43, | ||
blue: 44, | ||
magenta: 45, | ||
cyan: 46, | ||
brightRed: 101, | ||
brightGreen: 102, | ||
brightYellow: 103, | ||
brightBlue: 104, | ||
brightMagenta: 105, | ||
brightCyan: 106, | ||
}; | ||
exports.format = { | ||
@@ -6,0 +23,0 @@ counter: (current, total, pad = '0') => { |
@@ -9,2 +9,2 @@ export type ParseAssertionOptions = { | ||
}; | ||
export declare const parseAssertion: (cb: () => void, options: ParseAssertionOptions) => void; | ||
export declare const parseAssertion: (cb: () => void | Promise<void>, options: ParseAssertionOptions) => Promise<void>; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -13,26 +22,5 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const hr_js_1 = require("./hr.js"); | ||
const findFile = (error) => { | ||
var _a; | ||
const stackLines = ((_a = error.stack) === null || _a === void 0 ? void 0 : _a.split(node_os_1.EOL)) || []; | ||
let file = ''; | ||
const basePath = 'poku/lib/'; | ||
for (const line of stackLines) { | ||
if (!line.includes(basePath)) { | ||
const match = line.match(/at\s(\/.+|file:.+)|^(\s+)at\smodule\scode\s\((\/.+|file:.+)\)/i); | ||
// Node and Deno | ||
if (match && match[1]) { | ||
file = match[1]; | ||
break; | ||
} | ||
// Bun | ||
if (match && match[3]) { | ||
file = match[3]; | ||
break; | ||
} | ||
} | ||
} | ||
return file; | ||
}; | ||
const formatFail = (str) => format_js_1.format.bold(format_js_1.format.fail(`β ${str}`)); | ||
const parseAssertion = (cb, options) => { | ||
const find_file_js_1 = require("./find-file.js"); | ||
const each_js_1 = require("../configs/each.js"); | ||
const parseAssertion = (cb, options) => __awaiter(void 0, void 0, void 0, function* () { | ||
var _a, _b; | ||
@@ -42,3 +30,15 @@ const isPoku = typeof ((_a = node_process_1.default.env) === null || _a === void 0 ? void 0 : _a.FILE) === 'string' && ((_b = node_process_1.default.env) === null || _b === void 0 ? void 0 : _b.FILE.length) > 0; | ||
try { | ||
cb(); | ||
if (typeof each_js_1.each.before.cb === 'function') { | ||
const beforeResult = each_js_1.each.before.cb(); | ||
if (beforeResult instanceof Promise) | ||
yield beforeResult; | ||
} | ||
const cbResult = cb(); | ||
if (cbResult instanceof Promise) | ||
yield cbResult; | ||
if (typeof each_js_1.each.after.cb === 'function') { | ||
const afterResult = each_js_1.each.after.cb(); | ||
if (afterResult instanceof Promise) | ||
yield afterResult; | ||
} | ||
if (typeof options.message === 'string') { | ||
@@ -54,3 +54,3 @@ const message = isPoku | ||
const { code, actual, expected, operator } = error; | ||
const absoultePath = findFile(error).replace(/file:/, ''); | ||
const absoultePath = (0, find_file_js_1.findFile)(error).replace(/file:(\/\/)?/, ''); | ||
const file = node_path_1.default.relative(node_path_1.default.resolve(node_process_1.default.cwd()), absoultePath); | ||
@@ -65,4 +65,4 @@ let message = ''; | ||
const finalMessage = (message === null || message === void 0 ? void 0 : message.trim().length) > 0 | ||
? `${formatFail(message)}` | ||
: `${formatFail('No Message')}`; | ||
? format_js_1.format.bold(format_js_1.format.fail(`β ${message}`)) | ||
: format_js_1.format.bold(format_js_1.format.fail('β No Message')); | ||
console.log(isPoku | ||
@@ -93,3 +93,3 @@ ? `${finalMessage} ${format_js_1.format.dim(format_js_1.format.fail(`βΊ ${FILE}`))}` | ||
} | ||
}; | ||
}); | ||
exports.parseAssertion = parseAssertion; |
export { poku } from './modules/poku.js'; | ||
export { exit } from './modules/exit.js'; | ||
export { assert } from './modules/assert.js'; | ||
export { describe, log } from './modules/describe.js'; | ||
export { assertPromise } from './modules/assert-promise.js'; | ||
@@ -5,0 +6,0 @@ export { beforeEach, afterEach } from './modules/each.js'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.listFiles = exports.afterEach = exports.beforeEach = exports.assertPromise = exports.assert = exports.exit = exports.poku = void 0; | ||
exports.listFiles = exports.afterEach = exports.beforeEach = exports.assertPromise = exports.log = exports.describe = exports.assert = exports.exit = exports.poku = void 0; | ||
var poku_js_1 = require("./modules/poku.js"); | ||
@@ -10,2 +10,5 @@ Object.defineProperty(exports, "poku", { enumerable: true, get: function () { return poku_js_1.poku; } }); | ||
Object.defineProperty(exports, "assert", { enumerable: true, get: function () { return assert_js_1.assert; } }); | ||
var describe_js_1 = require("./modules/describe.js"); | ||
Object.defineProperty(exports, "describe", { enumerable: true, get: function () { return describe_js_1.describe; } }); | ||
Object.defineProperty(exports, "log", { enumerable: true, get: function () { return describe_js_1.log; } }); | ||
var assert_promise_js_1 = require("./modules/assert-promise.js"); | ||
@@ -12,0 +15,0 @@ Object.defineProperty(exports, "assertPromise", { enumerable: true, get: function () { return assert_promise_js_1.assertPromise; } }); |
/// <reference types="node" /> | ||
import * as nodeAssert from 'node:assert'; | ||
import { ParseAssertionOptions } from '../helpers/parseAsssetion.js'; | ||
declare function doesNotThrow(block: () => unknown, message?: string | ParseAssertionOptions['message']): Promise<void>; | ||
declare function doesNotThrow(block: () => unknown, error: nodeAssert.AssertPredicate, message?: ParseAssertionOptions['message']): Promise<void>; | ||
declare function throws(block: () => unknown, message?: ParseAssertionOptions['message']): Promise<void>; | ||
declare function throws(block: () => unknown, error: nodeAssert.AssertPredicate, message?: ParseAssertionOptions['message']): Promise<void>; | ||
declare function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>; | ||
declare function rejects(block: (() => Promise<unknown>) | Promise<unknown>, error: nodeAssert.AssertPredicate, message?: string | Error): Promise<void>; | ||
declare function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>; | ||
declare function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, error: nodeAssert.AssertPredicate, message?: string | Error): Promise<void>; | ||
declare function doesNotThrow(block: () => unknown, message?: string | ParseAssertionOptions['message']): void; | ||
declare function doesNotThrow(block: () => unknown, error: nodeAssert.AssertPredicate, message?: ParseAssertionOptions['message']): void; | ||
declare function throws(block: () => unknown, message?: ParseAssertionOptions['message']): void; | ||
declare function throws(block: () => unknown, error: nodeAssert.AssertPredicate, message?: ParseAssertionOptions['message']): void; | ||
declare function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>; | ||
declare function rejects(block: (() => Promise<unknown>) | Promise<unknown>, error: nodeAssert.AssertPredicate, message?: string | Error): Promise<void>; | ||
export declare const assertPromise: ((value: unknown, message?: ParseAssertionOptions['message']) => Promise<void>) & { | ||
@@ -28,5 +28,5 @@ ok: (value: unknown, message?: ParseAssertionOptions['message']) => Promise<void>; | ||
ifError: (value: unknown) => Promise<void>; | ||
fail: (message?: ParseAssertionOptions['message']) => void; | ||
fail: (message?: ParseAssertionOptions['message']) => Promise<void>; | ||
rejects: typeof rejects; | ||
}; | ||
export {}; |
@@ -34,265 +34,100 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.assertPromise = void 0; | ||
const node_process_1 = __importDefault(require("process")); | ||
const nodeAssert = __importStar(require("assert")); | ||
const parseAsssetion_js_1 = require("../helpers/parseAsssetion.js"); | ||
const assert_js_1 = require("./assert.js"); | ||
const get_runtime_js_1 = require("../helpers/get-runtime.js"); | ||
const runtime = (0, get_runtime_js_1.getRuntime)(); | ||
const version = runtime === 'node' | ||
? Number((_a = node_process_1.default.version.match(/v(\d+)\./)) === null || _a === void 0 ? void 0 : _a[1]) | ||
: undefined; | ||
const ok = (value, message) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.ok(value), { message }); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => { | ||
nodeAssert.ok(value); | ||
}, { message }); | ||
}); | ||
const equal = (actual, expected, message) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.equal(actual, expected), { message }); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => { | ||
nodeAssert.equal(actual, expected); | ||
}, { message }); | ||
}); | ||
const deepEqual = (actual, expected, message) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.deepEqual(actual, expected), { | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.deepEqual(actual, expected), { | ||
message, | ||
}); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
}); | ||
const strictEqual = (actual, expected, message) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.strictEqual(actual, expected), { | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.strictEqual(actual, expected), { | ||
message, | ||
}); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
}); | ||
const deepStrictEqual = (actual, expected, message) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.deepStrictEqual(actual, expected), { | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.deepStrictEqual(actual, expected), { | ||
message, | ||
}); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
}); | ||
const doesNotMatch = (value, regExp, message) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.doesNotMatch(value, regExp), { | ||
message, | ||
}); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
}); | ||
function doesNotReject(block, errorOrMessage, message) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (typeof errorOrMessage === 'function' || | ||
errorOrMessage instanceof RegExp || | ||
typeof errorOrMessage === 'object') { | ||
try { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
yield nodeAssert.doesNotReject(block, errorOrMessage); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
} | ||
catch (error) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error; | ||
}, { | ||
message, | ||
defaultMessage: 'Got unwanted rejection', | ||
hideDiff: true, | ||
throw: true, | ||
}); | ||
} | ||
} | ||
else { | ||
try { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
yield nodeAssert.doesNotReject(block); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
} | ||
catch (error_1) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error_1; | ||
}, { | ||
message: typeof errorOrMessage === 'string' ? errorOrMessage : undefined, | ||
defaultMessage: 'Got unwanted rejection', | ||
hideDiff: true, | ||
throw: true, | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
function doesNotThrow(block, errorOrMessage, message) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (typeof errorOrMessage === 'function' || | ||
errorOrMessage instanceof RegExp || | ||
typeof errorOrMessage === 'object') { | ||
try { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
nodeAssert.doesNotThrow(block, errorOrMessage, message); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
} | ||
catch (error) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error; | ||
}, { | ||
message: message, | ||
defaultMessage: 'Expected function not to throw', | ||
hideDiff: true, | ||
throw: true, | ||
}); | ||
} | ||
} | ||
else { | ||
const msg = typeof errorOrMessage === 'string' ? errorOrMessage : undefined; | ||
try { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
nodeAssert.doesNotThrow(block, msg); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
} | ||
catch (error) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error; | ||
}, { | ||
message: msg, | ||
defaultMessage: 'Expected function not to throw', | ||
hideDiff: true, | ||
throw: true, | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
function throws(block, errorOrMessage, message) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (typeof errorOrMessage === 'function' || | ||
errorOrMessage instanceof RegExp || | ||
typeof errorOrMessage === 'object') { | ||
try { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
nodeAssert.throws(block, errorOrMessage, message); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
} | ||
catch (error) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error; | ||
}, { | ||
message: message, | ||
defaultMessage: 'Expected function to throw', | ||
hideDiff: true, | ||
}); | ||
} | ||
} | ||
else { | ||
const msg = typeof errorOrMessage === 'string' ? errorOrMessage : undefined; | ||
try { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
nodeAssert.throws(block, message); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
} | ||
catch (error) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error; | ||
}, { | ||
message: msg, | ||
defaultMessage: 'Expected function to throw', | ||
hideDiff: true, | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
const notEqual = (actual, expected, message) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.notEqual(actual, expected), { | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.notEqual(actual, expected), { | ||
message, | ||
}); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
}); | ||
const notDeepEqual = (actual, expected, message) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.notDeepEqual(actual, expected), { | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.notDeepEqual(actual, expected), { | ||
message, | ||
}); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
}); | ||
const notStrictEqual = (actual, expected, message) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.notStrictEqual(actual, expected), { | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.notStrictEqual(actual, expected), { | ||
message, | ||
}); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
}); | ||
const notDeepStrictEqual = (actual, expected, message) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.notDeepStrictEqual(actual, expected), { | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.notDeepStrictEqual(actual, expected), { | ||
message, | ||
}); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
}); | ||
const match = (value, regExp, message) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.match(value, regExp), { message }); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
}); | ||
const ifError = (value) => __awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => { | ||
nodeAssert.ifError(value); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
} | ||
catch (error) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error; | ||
}, { | ||
defaultMessage: 'Expected no error, but received an error', | ||
hideDiff: true, | ||
throw: true, | ||
}); | ||
} | ||
}, { | ||
defaultMessage: 'Expected no error, but received an error', | ||
hideDiff: true, | ||
throw: true, | ||
}); | ||
}); | ||
const fail = (message) => { | ||
try { | ||
const fail = (message) => __awaiter(void 0, void 0, void 0, function* () { | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => { | ||
nodeAssert.fail(message); | ||
} | ||
catch (error) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error; | ||
}, { | ||
message, | ||
defaultMessage: 'Test failed intentionally', | ||
hideDiff: true, | ||
}); | ||
}); | ||
function doesNotThrow(block, errorOrMessage, message) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => { | ||
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, | ||
defaultMessage: 'Test failed intentionally', | ||
message: typeof errorOrMessage === 'string' ? errorOrMessage : message, | ||
defaultMessage: 'Expected function not to throw', | ||
hideDiff: true, | ||
throw: true, | ||
}); | ||
} | ||
}; | ||
function rejects(block, errorOrMessage, message) { | ||
}); | ||
} | ||
function throws(block, errorOrMessage, message) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -302,40 +137,77 @@ if (typeof errorOrMessage === 'function' || | ||
typeof errorOrMessage === 'object') { | ||
try { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
yield nodeAssert.rejects(block, errorOrMessage); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
} | ||
catch (error) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error; | ||
}, { | ||
message, | ||
defaultMessage: 'Expected promise to be rejected with specified error', | ||
hideDiff: true, | ||
}); | ||
} | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.throws(block, errorOrMessage), { | ||
message, | ||
defaultMessage: 'Expected function to throw', | ||
hideDiff: true, | ||
}); | ||
} | ||
else { | ||
const msg = typeof errorOrMessage === 'string' ? errorOrMessage : undefined; | ||
try { | ||
if (assert_js_1.each.before) | ||
yield assert_js_1.each.before(); | ||
yield nodeAssert.rejects(block); | ||
if (assert_js_1.each.after) | ||
yield assert_js_1.each.after(); | ||
const msg = typeof errorOrMessage !== 'undefined' ? errorOrMessage : message; | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.throws(block, message), { | ||
message: msg, | ||
defaultMessage: 'Expected function to throw', | ||
hideDiff: true, | ||
}); | ||
} | ||
}); | ||
} | ||
function rejects(block, errorOrMessage, message) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => __awaiter(this, void 0, void 0, function* () { | ||
if (typeof errorOrMessage === 'function' || | ||
errorOrMessage instanceof RegExp || | ||
typeof errorOrMessage === 'object') { | ||
yield nodeAssert.rejects(block, errorOrMessage, message); | ||
} | ||
catch (error_1) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error_1; | ||
}, { | ||
message: msg, | ||
defaultMessage: 'Expected promise to be rejected', | ||
hideDiff: true, | ||
}); | ||
else { | ||
const msg = typeof errorOrMessage === 'string' ? errorOrMessage : message; | ||
yield nodeAssert.rejects(block, msg); | ||
} | ||
} | ||
}), { | ||
message: typeof errorOrMessage === 'string' ? errorOrMessage : message, | ||
defaultMessage: 'Expected promise to be rejected with specified error', | ||
hideDiff: true, | ||
throw: true, | ||
}); | ||
}); | ||
} | ||
function doesNotReject(block, errorOrMessage, message) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => __awaiter(this, void 0, void 0, function* () { | ||
if (typeof errorOrMessage === 'function' || | ||
errorOrMessage instanceof RegExp || | ||
typeof errorOrMessage === 'object') | ||
yield nodeAssert.doesNotReject(block, errorOrMessage, message); | ||
else | ||
yield nodeAssert.doesNotReject(block, message); | ||
}), { | ||
message: typeof errorOrMessage === 'string' ? errorOrMessage : message, | ||
defaultMessage: 'Got unwanted rejection', | ||
hideDiff: true, | ||
throw: true, | ||
}); | ||
}); | ||
} | ||
const match = (value, regExp, message) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (typeof version === 'number' && version < 12) { | ||
throw new Error('doesNotMatch is available from Node.js 12 or higher'); | ||
} | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => 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) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (typeof version === 'number' && version < 12) { | ||
throw new Error('doesNotMatch is available from Node.js 12 or higher'); | ||
} | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.doesNotMatch(value, regExp), { | ||
message, | ||
actual: 'Value', | ||
expected: 'RegExp', | ||
defaultMessage: 'Value should not match regExp', | ||
}); | ||
}); | ||
exports.assertPromise = Object.assign((value, message) => ok(value, message), { | ||
@@ -342,0 +214,0 @@ ok, |
/// <reference types="node" /> | ||
import * as nodeAssert from 'node:assert'; | ||
import { ParseAssertionOptions } from '../helpers/parseAsssetion.js'; | ||
type Each = { | ||
before?: undefined | (() => unknown); | ||
after?: undefined | (() => unknown); | ||
}; | ||
export declare const each: Each; | ||
declare function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>; | ||
declare function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, error: nodeAssert.AssertPredicate, message?: string | Error): Promise<void>; | ||
declare function doesNotThrow(block: () => unknown, message?: string | ParseAssertionOptions['message']): void; | ||
@@ -17,2 +10,4 @@ declare function doesNotThrow(block: () => unknown, error: nodeAssert.AssertPredicate, message?: ParseAssertionOptions['message']): void; | ||
declare function rejects(block: (() => Promise<unknown>) | Promise<unknown>, error: nodeAssert.AssertPredicate, message?: string | Error): Promise<void>; | ||
declare function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>; | ||
declare function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, error: nodeAssert.AssertPredicate, message?: string | Error): Promise<void>; | ||
export declare const assert: ((value: unknown, message?: ParseAssertionOptions['message']) => void) & { | ||
@@ -19,0 +14,0 @@ ok: (value: unknown, message?: ParseAssertionOptions['message']) => void; |
@@ -34,268 +34,169 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.assert = exports.each = void 0; | ||
exports.assert = void 0; | ||
const node_process_1 = __importDefault(require("process")); | ||
const nodeAssert = __importStar(require("assert")); | ||
const parseAsssetion_js_1 = require("../helpers/parseAsssetion.js"); | ||
exports.each = { | ||
before: undefined, | ||
after: undefined, | ||
}; | ||
const get_runtime_js_1 = require("../helpers/get-runtime.js"); | ||
const runtime = (0, get_runtime_js_1.getRuntime)(); | ||
const version = runtime === 'node' | ||
? Number((_a = node_process_1.default.version.match(/v(\d+)\./)) === null || _a === void 0 ? void 0 : _a[1]) | ||
: undefined; | ||
const ok = (value, message) => { | ||
exports.each.before && exports.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.ok(value), { message }); | ||
exports.each.after && exports.each.after(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
nodeAssert.ok(value); | ||
}, { message }); | ||
}; | ||
const equal = (actual, expected, message) => { | ||
exports.each.before && exports.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.equal(actual, expected), { message }); | ||
exports.each.after && exports.each.after(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
nodeAssert.equal(actual, expected); | ||
}, { message }); | ||
}; | ||
const deepEqual = (actual, expected, message) => { | ||
exports.each.before && exports.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.deepEqual(actual, expected), { message }); | ||
exports.each.after && exports.each.after(); | ||
}; | ||
const strictEqual = (actual, expected, message) => { | ||
exports.each.before && exports.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.strictEqual(actual, expected), { message }); | ||
exports.each.after && exports.each.after(); | ||
}; | ||
const deepStrictEqual = (actual, expected, message) => { | ||
exports.each.before && exports.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.deepStrictEqual(actual, expected), { | ||
message, | ||
}); | ||
exports.each.after && exports.each.after(); | ||
}; | ||
const doesNotMatch = (value, regExp, message) => { | ||
exports.each.before && exports.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.doesNotMatch(value, regExp), { | ||
message, | ||
actual: 'Value', | ||
expected: 'RegExp', | ||
defaultMessage: 'Value should not match regExp', | ||
}); | ||
exports.each.after && exports.each.after(); | ||
}; | ||
function doesNotReject(block, errorOrMessage, message) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (typeof errorOrMessage === 'function' || | ||
errorOrMessage instanceof RegExp || | ||
typeof errorOrMessage === 'object') { | ||
try { | ||
exports.each.before && exports.each.before(); | ||
yield nodeAssert.doesNotReject(block, errorOrMessage); | ||
exports.each.after && exports.each.after(); | ||
} | ||
catch (error) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error; | ||
}, { | ||
message, | ||
defaultMessage: 'Got unwanted rejection', | ||
hideDiff: true, | ||
throw: true, | ||
}); | ||
} | ||
} | ||
else { | ||
try { | ||
exports.each.before && exports.each.before(); | ||
yield nodeAssert.doesNotReject(block); | ||
exports.each.after && exports.each.after(); | ||
} | ||
catch (error_1) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error_1; | ||
}, { | ||
message: typeof errorOrMessage === 'string' ? errorOrMessage : undefined, | ||
defaultMessage: 'Got unwanted rejection', | ||
hideDiff: true, | ||
throw: true, | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
function doesNotThrow(block, errorOrMessage, message) { | ||
if (typeof errorOrMessage === 'function' || | ||
errorOrMessage instanceof RegExp || | ||
typeof errorOrMessage === 'object') { | ||
try { | ||
exports.each.before && exports.each.before(); | ||
nodeAssert.doesNotThrow(block, errorOrMessage, message); | ||
exports.each.after && exports.each.after(); | ||
} | ||
catch (error) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error; | ||
}, { | ||
message: message, | ||
defaultMessage: 'Expected function not to throw', | ||
hideDiff: true, | ||
throw: true, | ||
}); | ||
} | ||
} | ||
else { | ||
const msg = typeof errorOrMessage === 'string' ? errorOrMessage : undefined; | ||
try { | ||
exports.each.before && exports.each.before(); | ||
nodeAssert.doesNotThrow(block, msg); | ||
exports.each.after && exports.each.after(); | ||
} | ||
catch (error) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error; | ||
}, { | ||
message: msg, | ||
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') { | ||
try { | ||
exports.each.before && exports.each.before(); | ||
nodeAssert.throws(block, errorOrMessage, message); | ||
exports.each.after && exports.each.after(); | ||
} | ||
catch (error) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error; | ||
}, { | ||
message: message, | ||
defaultMessage: 'Expected function to throw', | ||
hideDiff: true, | ||
}); | ||
} | ||
} | ||
else { | ||
const msg = typeof errorOrMessage === 'string' ? errorOrMessage : undefined; | ||
try { | ||
exports.each.before && exports.each.before(); | ||
nodeAssert.throws(block, message); | ||
exports.each.after && exports.each.after(); | ||
} | ||
catch (error) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error; | ||
}, { | ||
message: msg, | ||
defaultMessage: 'Expected function to throw', | ||
hideDiff: true, | ||
}); | ||
} | ||
} | ||
} | ||
const notEqual = (actual, expected, message) => { | ||
exports.each.before && exports.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.notEqual(actual, expected), { | ||
message, | ||
}); | ||
exports.each.after && exports.each.after(); | ||
}; | ||
const notDeepEqual = (actual, expected, message) => { | ||
exports.each.before && exports.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.notDeepEqual(actual, expected), { message }); | ||
exports.each.after && exports.each.after(); | ||
}; | ||
const notStrictEqual = (actual, expected, message) => { | ||
exports.each.before && exports.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.notStrictEqual(actual, expected), { | ||
message, | ||
}); | ||
exports.each.after && exports.each.after(); | ||
}; | ||
const notDeepStrictEqual = (actual, expected, message) => { | ||
exports.each.before && exports.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.notDeepStrictEqual(actual, expected), { | ||
message, | ||
}); | ||
exports.each.after && exports.each.after(); | ||
}; | ||
const match = (value, regExp, message) => { | ||
exports.each.before && exports.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.match(value, regExp), { | ||
message, | ||
actual: 'Value', | ||
expected: 'RegExp', | ||
defaultMessage: 'Value should match regExp', | ||
}); | ||
exports.each.after && exports.each.after(); | ||
}; | ||
const ifError = (value) => { | ||
try { | ||
exports.each.before && exports.each.before(); | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
nodeAssert.ifError(value); | ||
exports.each.after && exports.each.after(); | ||
} | ||
catch (error) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error; | ||
}, { | ||
defaultMessage: 'Expected no error, but received an error', | ||
hideDiff: true, | ||
throw: true, | ||
}); | ||
} | ||
}, { | ||
defaultMessage: 'Expected no error, but received an error', | ||
hideDiff: true, | ||
throw: true, | ||
}); | ||
}; | ||
const fail = (message) => { | ||
try { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
nodeAssert.fail(message); | ||
} | ||
catch (error) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error; | ||
}, { | ||
}, { | ||
message, | ||
defaultMessage: 'Test failed intentionally', | ||
hideDiff: true, | ||
}); | ||
}; | ||
function doesNotThrow(block, errorOrMessage, message) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
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, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.throws(block, errorOrMessage), { | ||
message, | ||
defaultMessage: 'Test failed intentionally', | ||
defaultMessage: 'Expected function to throw', | ||
hideDiff: true, | ||
}); | ||
} | ||
}; | ||
else { | ||
const msg = typeof errorOrMessage !== 'undefined' ? errorOrMessage : message; | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.throws(block, message), { | ||
message: msg, | ||
defaultMessage: 'Expected function to throw', | ||
hideDiff: true, | ||
}); | ||
} | ||
} | ||
function rejects(block, errorOrMessage, message) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (typeof errorOrMessage === 'function' || | ||
errorOrMessage instanceof RegExp || | ||
typeof errorOrMessage === 'object') { | ||
try { | ||
exports.each.before && exports.each.before(); | ||
yield nodeAssert.rejects(block, errorOrMessage); | ||
exports.each.after && exports.each.after(); | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => __awaiter(this, void 0, void 0, function* () { | ||
if (typeof errorOrMessage === 'function' || | ||
errorOrMessage instanceof RegExp || | ||
typeof errorOrMessage === 'object') { | ||
yield nodeAssert.rejects(block, errorOrMessage, message); | ||
} | ||
catch (error) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error; | ||
}, { | ||
message, | ||
defaultMessage: 'Expected promise to be rejected with specified error', | ||
hideDiff: true, | ||
}); | ||
else { | ||
const msg = typeof errorOrMessage === 'string' ? errorOrMessage : message; | ||
yield nodeAssert.rejects(block, msg); | ||
} | ||
} | ||
else { | ||
const msg = typeof errorOrMessage === 'string' ? errorOrMessage : undefined; | ||
try { | ||
exports.each.before && exports.each.before(); | ||
yield nodeAssert.rejects(block); | ||
exports.each.after && exports.each.after(); | ||
} | ||
catch (error_1) { | ||
(0, parseAsssetion_js_1.parseAssertion)(() => { | ||
throw error_1; | ||
}, { | ||
message: msg, | ||
defaultMessage: 'Expected promise to be rejected', | ||
hideDiff: true, | ||
}); | ||
} | ||
} | ||
}), { | ||
message: typeof errorOrMessage === 'string' ? errorOrMessage : message, | ||
defaultMessage: 'Expected promise to be rejected with specified error', | ||
hideDiff: true, | ||
throw: true, | ||
}); | ||
}); | ||
} | ||
function doesNotReject(block, errorOrMessage, message) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield (0, parseAsssetion_js_1.parseAssertion)(() => __awaiter(this, void 0, void 0, function* () { | ||
if (typeof errorOrMessage === 'function' || | ||
errorOrMessage instanceof RegExp || | ||
typeof errorOrMessage === 'object') | ||
yield nodeAssert.doesNotReject(block, errorOrMessage, message); | ||
else | ||
yield 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 version === 'number' && version < 12) { | ||
throw new Error('doesNotMatch is available from Node.js 12 or higher'); | ||
} | ||
(0, parseAsssetion_js_1.parseAssertion)(() => 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 version === 'number' && version < 12) { | ||
throw new Error('doesNotMatch is available from Node.js 12 or higher'); | ||
} | ||
(0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.doesNotMatch(value, regExp), { | ||
message, | ||
actual: 'Value', | ||
expected: 'RegExp', | ||
defaultMessage: 'Value should not match regExp', | ||
}); | ||
}; | ||
exports.assert = Object.assign((value, message) => ok(value, message), { | ||
@@ -302,0 +203,0 @@ ok, |
@@ -1,5 +0,4 @@ | ||
type Control = { | ||
pause: () => void; | ||
continue: () => void; | ||
reset: () => void; | ||
import { Control } from '../configs/each.js'; | ||
type EachOptions = { | ||
immediate?: boolean; | ||
}; | ||
@@ -9,3 +8,3 @@ /** | ||
* - β It's made for **exclusive use** in combination with **Poku**'s **`assert`** methods | ||
* - β Changing local variables values and states ([_use a mock instead_](https://poku.dev/docs/category/mock)) | ||
* - β οΈ Although `beforeEach` accepts local variables changes by using the `imediate` option, it's strongly discouraged ([_use a mock instead_](https://poku.io/docs/category/mock)) | ||
* | ||
@@ -28,7 +27,7 @@ * --- | ||
*/ | ||
export declare const beforeEach: (callback: () => unknown) => Control; | ||
export declare const beforeEach: (callback: () => unknown, options?: EachOptions) => Control; | ||
/** | ||
* - β Handling **global** and **external** services (_preparing a database, for example_) | ||
* - β It's made for **exclusive use** in combination with **Poku**'s **`assert`** methods | ||
* - β Changing local variables values and states ([_use a mock instead_](https://poku.dev/docs/category/mock)) | ||
* - β οΈ Although `afterEach` accepts local variables changes, it's strongly discouraged ([_use a mock instead_](https://poku.io/docs/category/mock)) | ||
* | ||
@@ -35,0 +34,0 @@ * --- |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.afterEach = exports.beforeEach = void 0; | ||
const assert_js_1 = require("../modules/assert.js"); | ||
const status = { | ||
before: true, | ||
after: true, | ||
}; | ||
const each_js_1 = require("../configs/each.js"); | ||
/** | ||
* - β Handling **global** and **external** services (_preparing a database, for example_) | ||
* - β It's made for **exclusive use** in combination with **Poku**'s **`assert`** methods | ||
* - β Changing local variables values and states ([_use a mock instead_](https://poku.dev/docs/category/mock)) | ||
* - β οΈ Although `beforeEach` accepts local variables changes by using the `imediate` option, it's strongly discouraged ([_use a mock instead_](https://poku.io/docs/category/mock)) | ||
* | ||
@@ -30,15 +26,16 @@ * --- | ||
*/ | ||
const beforeEach = (callback) => { | ||
assert_js_1.each.before = () => { | ||
if (status.before) | ||
const beforeEach = (callback, options) => { | ||
(options === null || options === void 0 ? void 0 : options.immediate) && callback(); | ||
each_js_1.each.before.cb = () => { | ||
if (each_js_1.each.before.status) | ||
callback(); | ||
}; | ||
const pause = () => { | ||
status.before = false; | ||
each_js_1.each.before.status = false; | ||
}; | ||
const continueFunc = () => { | ||
status.before = true; | ||
each_js_1.each.before.status = true; | ||
}; | ||
const reset = () => { | ||
assert_js_1.each.before = undefined; | ||
each_js_1.each.before.cb = undefined; | ||
}; | ||
@@ -51,3 +48,3 @@ return { pause, continue: continueFunc, reset }; | ||
* - β It's made for **exclusive use** in combination with **Poku**'s **`assert`** methods | ||
* - β Changing local variables values and states ([_use a mock instead_](https://poku.dev/docs/category/mock)) | ||
* - β οΈ Although `afterEach` accepts local variables changes, it's strongly discouraged ([_use a mock instead_](https://poku.io/docs/category/mock)) | ||
* | ||
@@ -71,14 +68,14 @@ * --- | ||
const afterEach = (callback) => { | ||
assert_js_1.each.after = () => { | ||
if (status.after) | ||
each_js_1.each.after.cb = () => { | ||
if (each_js_1.each.after.status) | ||
callback(); | ||
}; | ||
const pause = () => { | ||
status.after = false; | ||
each_js_1.each.after.status = false; | ||
}; | ||
const continueFunc = () => { | ||
status.after = true; | ||
each_js_1.each.after.status = true; | ||
}; | ||
const reset = () => { | ||
assert_js_1.each.after = undefined; | ||
each_js_1.each.after.cb = undefined; | ||
}; | ||
@@ -85,0 +82,0 @@ return { pause, continue: continueFunc, reset }; |
{ | ||
"name": "poku", | ||
"version": "1.6.1", | ||
"version": "1.7.0", | ||
"description": "π· Poku makes testing easy for Node.js, Bun & Deno at the same time.", | ||
@@ -8,4 +8,5 @@ "main": "./lib/index.js", | ||
"test": "npx tsx --tsconfig ./tsconfig.test.json ./test/run.test.ts", | ||
"pretest:coverage": "npm run build", | ||
"test:coverage": "docker compose -f test/docker/docker-compose.coverage.yml up", | ||
"pretest:c8": "npm run build", | ||
"test:c8": "docker compose -f test/docker/docker-compose.c8.yml up", | ||
"test:ci:c8": "npx c8 --include 'src/**' --exclude 'src/@types/**' --reporter=text --reporter=lcov npx tsx test/run.test.ts", | ||
"test:ci": "tsx ./test/ci.test.ts", | ||
@@ -16,2 +17,4 @@ "test:node": "FILTER='node-' npm run test:ci", | ||
"prebuild": "rm -rf ./lib ./ci", | ||
"predocker:deno": "docker compose -f ./test/docker/playground/deno/docker-compose.yml down", | ||
"docker:deno": "docker compose -f ./test/docker/playground/deno/docker-compose.yml up --build", | ||
"build": "npx tsc; npx tsc -p tsconfig.test.json", | ||
@@ -32,3 +35,3 @@ "postbuild": "npx tsx ./tools/compatibility/node.ts; chmod +x lib/bin/index.js; npm audit", | ||
}, | ||
"homepage": "https://poku.dev", | ||
"homepage": "https://poku.io", | ||
"bin": { | ||
@@ -79,3 +82,4 @@ "poku": "./lib/bin/index.js" | ||
"easy", | ||
"poku" | ||
"poku", | ||
"pokujs" | ||
], | ||
@@ -100,2 +104,3 @@ "author": "https://github.com/wellwelwel", | ||
"@typescript-eslint/parser": "^7.1.0", | ||
"c8": "^9.1.0", | ||
"eslint": "^8.57.0", | ||
@@ -106,3 +111,2 @@ "eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"nyc": "^15.1.0", | ||
"packages-update": "^1.2.1", | ||
@@ -109,0 +113,0 @@ "prettier": "^3.2.5", |
@@ -20,4 +20,6 @@ [node-version-url]: https://github.com/nodejs/node | ||
<img align="right" width="128" height="128" alt="Logo" src=".github/assets/readme/poku.svg"> | ||
<img align="right" width="128" height="128" alt="Logo" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/poku.svg"> | ||
[**English**](https://poku.io/docs) | [**PortuguΓͺs (BR)**](https://poku.io/pt-BR/docs) | ||
**Poku** is your Test Runner Pet for [**Node.js**][node-version-url], [**Bun**][bun-version-url] and [**Deno**][deno-version-url]. | ||
@@ -34,2 +36,4 @@ | ||
<!-- ![Codecov](https://img.shields.io/codecov/c/github/wellwelwel/poku?label=Coverage) --> | ||
Enjoying **Poku**? Consider giving him a star βοΈ | ||
@@ -39,3 +43,3 @@ | ||
π· [**Documentation**](https://poku.dev) β’ π§ͺ [**Examples**](https://poku.dev/docs/category/examples) β’ π¬ [**Compare the Most Popular Test Runners**](https://poku.dev/docs/comparing) | ||
π· [**Documentation**](https://poku.io) β’ π§ͺ [**Examples**](https://poku.io/docs/category/examples) β’ π¬ [**Compare the Most Popular Test Runners**](https://poku.io/docs/comparing) | ||
@@ -51,2 +55,3 @@ --- | ||
- High **isolation** level per file | ||
- **Poku** is [**100%** documented](https://poku.io/docs) | ||
- Zero external dependencies | ||
@@ -63,4 +68,6 @@ - **Parallel** and **Sequential** runs | ||
## Install | ||
## Quickstart | ||
### Install π¦ | ||
[![Install Size](https://packagephobia.com/badge?p=poku)](https://packagephobia.com/result?p=poku) | ||
@@ -70,6 +77,6 @@ | ||
<tr> | ||
<th><img src=".github/assets/readme/node-js.svg" width="24" /></th> | ||
<th><img src=".github/assets/readme/node-js.svg" width="24" /> <img src=".github/assets/readme/plus.svg" width="24" /> <img src=".github/assets/readme/typescript.svg" width="24" /></th> | ||
<th><img src=".github/assets/readme/bun.svg" width="24" /></th> | ||
<th><img src=".github/assets/readme/deno.svg" width="24" /></th> | ||
<td><img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/node-js.svg" width="24" /></td> | ||
<td><img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/node-js.svg" width="24" /> <img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/plus.svg" width="24" /> <img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/typescript.svg" width="24" /></td> | ||
<td><img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/bun.svg" width="24" /></td> | ||
<td><img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/deno.svg" width="24" /></td> | ||
</tr> | ||
@@ -108,9 +115,12 @@ <tr> | ||
--- | ||
## Quick Start | ||
### Test it π¬ | ||
_`test/file.test.js`_ | ||
<table> | ||
<tr> | ||
<td> | ||
<em><code>test/file.test.js</code></em> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td width="1200"> | ||
@@ -120,6 +130,8 @@ ```ts | ||
assert(true, 'Poku will describe it π'); | ||
assert(true, 'Poku will describe it π·'); | ||
``` | ||
[**See the complete assert's documentation**](https://poku.dev/docs/documentation/assert). | ||
</td> | ||
</tr> | ||
</table> | ||
@@ -130,5 +142,5 @@ ### Run it π | ||
<tr> | ||
<th><img src=".github/assets/readme/node-js.svg" width="24" /></th> | ||
<th><img src=".github/assets/readme/bun.svg" width="24" /></th> | ||
<th><img src=".github/assets/readme/deno.svg" width="24" /></th> | ||
<td><img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/node-js.svg" width="24" /></td> | ||
<td><img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/bun.svg" width="24" /></td> | ||
<td><img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/deno.svg" width="24" /></td> | ||
</tr> | ||
@@ -160,6 +172,7 @@ <tr> | ||
[**See the complete `poku` documentation**](https://poku.dev/docs/category/poku). | ||
### That's it π | ||
- [**See the complete `assert`'s documentation**](https://poku.io/docs/documentation/assert). | ||
- [**See the complete `poku`'s documentation**](https://poku.io/docs/category/poku). | ||
--- | ||
@@ -171,7 +184,7 @@ | ||
| Sequential | Concurrent | | ||
| -------------------------------------------------- | ------------------------------------------------ | | ||
| <img src=".github/assets/readme/sequential.png" /> | <img src=".github/assets/readme/parallel.png" /> | | ||
| Sequential | Concurrent | | ||
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | ||
| <img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/sequential.png" /> | <img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/parallel.png" /> | | ||
> [**See the complete `poku` documentation**](https://poku.dev/docs/category/poku). | ||
> [**See the complete `poku`'s documentation**](https://poku.io/docs/category/poku). | ||
@@ -183,9 +196,9 @@ --- | ||
- π Use it exactly as it's for **Node.js** | ||
- π· **Node.js**, **Bun** and **Deno** compatibility. | ||
- π· **Node.js**, **Bun** and **Deno** compatibility | ||
| Using `poku` | Using `node` | | ||
| --------------------------------------------------- | --------------------------------------------------- | | ||
| <img src=".github/assets/readme/assert-poku.png" /> | <img src=".github/assets/readme/assert-node.png" /> | | ||
| Using `poku` | Using `node` | | ||
| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | | ||
| <img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/assert-poku.png" /> | <img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/assert-node.png" /> | | ||
> [**See the complete assert's documentation**](https://poku.dev/docs/documentation/assert). | ||
> [**See the complete `assert`'s documentation**](https://poku.io/docs/documentation/assert). | ||
@@ -196,3 +209,3 @@ --- | ||
To see the detailed documentation, please visit the [**Documentation**](https://poku.dev/docs/category/documentation) and [**Examples**](https://poku.dev/docs/category/examples) sections in the [**Poku**'s website](https://poku.dev). | ||
To see the detailed documentation, please visit the [**Documentation**](https://poku.io/docs/category/documentation) and [**Examples**](https://poku.io/docs/category/examples) sections in the [**Poku**'s website](https://poku.io). | ||
@@ -207,13 +220,11 @@ --- | ||
## Acknowledgements | ||
## Contributing | ||
[![Contributors](https://img.shields.io/github/contributors/wellwelwel/poku)](https://github.com/wellwelwel/poku/graphs/contributors) | ||
Please check the [**CONTRIBUTING.md**](./CONTRIBUTING.md) for instructions π | ||
[![Contributors](https://contrib.rocks/image?repo=wellwelwel/poku)](https://github.com/wellwelwel/poku/graphs/contributors) | ||
--- | ||
## Contributing | ||
## Philosophy | ||
Please check the [**CONTRIBUTING.md**](./CONTRIBUTING.md) for instructions π | ||
Please check the [**Philosophy**](https://poku.io/docs/philosophy) section from Documentation. | ||
@@ -224,3 +235,3 @@ --- | ||
Poku is under the [**MIT** License](./LICENSE). | ||
Poku is under the [**MIT License**](./LICENSE). | ||
@@ -231,6 +242,14 @@ --- | ||
Please check the [**SECURITY.md**](./SECURITY.md) and the section [**Is Poku Safe?**](https://poku.dev/docs/security) from Documentation. | ||
Please check the [**SECURITY.md**](./SECURITY.md) and the section [**Is Poku Safe?**](https://poku.io/docs/security) from Documentation. | ||
--- | ||
## Acknowledgements | ||
[![Contributors](https://img.shields.io/github/contributors/wellwelwel/poku)](https://github.com/wellwelwel/poku/graphs/contributors) | ||
[![Contributors](https://contrib.rocks/image?repo=wellwelwel/poku)](https://github.com/wellwelwel/poku/graphs/contributors) | ||
--- | ||
## Author | ||
@@ -237,0 +256,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86701
59
243
1657