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

poku

Package Overview
Dependencies
Maintainers
1
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 1.4.0 to 1.5.0

lib/helpers/remove-repeats.d.ts

11

lib/@types/poku.d.ts

@@ -12,2 +12,3 @@ import type { Configs as ListFilesConfigs } from './list-files.js';

/**
* @deprecated
* Customize `stdout` options.

@@ -17,2 +18,4 @@ */

/**
* @deprecated
*
* @default false

@@ -22,2 +25,4 @@ */

/**
* @deprecated
*
* @default true

@@ -32,2 +37,8 @@ */

*/
debug?: boolean;
/**
* This option overwrites the `debug` settings.
*
* @default false
*/
quiet?: boolean;

@@ -34,0 +45,0 @@ /**

9

lib/bin/index.js

@@ -9,2 +9,3 @@ #! /usr/bin/env node

const get_runtime_js_1 = require("../helpers/get-runtime.js");
const format_js_1 = require("../helpers/format.js");
const dirs = ((0, get_arg_js_1.hasArg)('include')

@@ -18,3 +19,5 @@ ? (_a = (0, get_arg_js_1.getArg)('include')) === null || _a === void 0 ? void 0 : _a.split(',')

const quiet = (0, get_arg_js_1.hasArg)('quiet');
const logSuccess = (0, get_arg_js_1.hasArg)('log-success');
const debug = (0, get_arg_js_1.hasArg)('debug');
if ((0, get_arg_js_1.hasArg)('log-success'))
console.log(`The flag ${format_js_1.format.bold('--log-success')} is deprecated. Use ${format_js_1.format.bold('--debug')} instead.`);
(0, index_js_1.poku)(dirs, {

@@ -26,5 +29,3 @@ platform: (0, get_runtime_js_1.platformIsValid)(platform) ? platform : undefined,

quiet,
log: {
success: logSuccess,
},
debug,
});

@@ -9,2 +9,4 @@ export declare const format: {

fail: (value: string) => string;
bg: (bg: number, text: string) => string;
};
export declare const getLargestStringLength: (arr: string[]) => number;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.format = void 0;
exports.getLargestStringLength = exports.format = void 0;
const pad_js_1 = require("./pad.js");

@@ -13,5 +13,12 @@ exports.format = {

underline: (value) => `\x1b[4m${value}\x1b[0m`,
info: (value) => `\x1b[36m${value}\x1b[0m`,
info: (value) => `\x1b[94m${value}\x1b[0m`,
success: (value) => `\x1b[32m${value}\x1b[0m`,
fail: (value) => `\x1b[31m${value}\x1b[0m`,
fail: (value) => `\x1b[91m${value}\x1b[0m`,
bg: (bg, text) => {
const padding = ' '.repeat(1);
const paddedText = `${padding}${text}${padding}`;
return `\x1b[${bg}m\x1b[1m${paddedText}\x1b[0m`;
},
};
const getLargestStringLength = (arr) => arr.reduce((max, current) => Math.max(max, current.length), 0);
exports.getLargestStringLength = getLargestStringLength;

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

const hr = () => {
const columns = node_process_1.default.stdout.columns;
const line = '_'.repeat(columns - 10 || 30);
console.log(`\x1b[2m${line}\x1b[0m${node_os_1.EOL}`);
const line = '⎯'.repeat(node_process_1.default.stdout.columns - 10);
console.log(`${node_os_1.EOL}\x1b[2m\x1b[90m${line}\x1b[0m${node_os_1.EOL}`);
};
exports.hr = hr;
import { Configs } from '../@types/poku.js';
export declare const isQuiet: (configs?: Configs) => boolean;
export declare const showSuccesses: (configs?: Configs) => boolean;
export declare const showFailures: (configs?: Configs) => boolean;
export declare const isDebug: (configs?: Configs) => boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.showFailures = exports.showSuccesses = exports.isQuiet = void 0;
exports.isDebug = exports.isQuiet = void 0;
const isQuiet = (configs) => typeof (configs === null || configs === void 0 ? void 0 : configs.quiet) === 'boolean' && Boolean(configs === null || configs === void 0 ? void 0 : configs.quiet);
exports.isQuiet = isQuiet;
const showSuccesses = (configs) => { var _a; return Boolean((_a = configs === null || configs === void 0 ? void 0 : configs.log) === null || _a === void 0 ? void 0 : _a.success); };
exports.showSuccesses = showSuccesses;
const showFailures = (configs) => { var _a, _b; return typeof ((_a = configs === null || configs === void 0 ? void 0 : configs.log) === null || _a === void 0 ? void 0 : _a.fail) === 'undefined' || Boolean((_b = configs === null || configs === void 0 ? void 0 : configs.log) === null || _b === void 0 ? void 0 : _b.fail); };
exports.showFailures = showFailures;
const isDebug = (configs) => Boolean(configs === null || configs === void 0 ? void 0 : configs.debug);
exports.isDebug = isDebug;

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

const node_process_1 = __importDefault(require("process"));
const node_path_1 = __importDefault(require("path"));
const node_assert_1 = __importDefault(require("assert"));

@@ -29,5 +30,15 @@ const node_os_1 = require("os");

};
const formatFail = (str) => format_js_1.format.bold(format_js_1.format.fail(`✘ ${str}`));
const parseAssertion = (cb, options) => {
var _a, _b;
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;
const FILE = node_process_1.default.env.FILE;
try {
cb();
if (typeof options.message === 'string') {
const message = isPoku
? `${format_js_1.format.bold(format_js_1.format.success(`✔ ${options.message}`))} ${format_js_1.format.dim(format_js_1.format.success(`› ${FILE}`))}`
: format_js_1.format.bold(format_js_1.format.success(`✔ ${options.message}`));
console.log(message);
}
}

@@ -37,24 +48,29 @@ catch (error) {

const { code, actual, expected, operator } = error;
const file = findFile(error);
(0, hr_js_1.hr)();
const absoultePath = findFile(error);
const file = node_path_1.default.relative(node_path_1.default.resolve(node_process_1.default.cwd()), absoultePath);
let message = '';
if (typeof options.message === 'string')
console.log(format_js_1.format.bold(options.message), node_os_1.EOL);
message = options.message;
else if (options.message instanceof Error)
console.log(format_js_1.format.bold(options.message.message), node_os_1.EOL);
message = options.message.message;
else if (typeof options.defaultMessage === 'string')
console.log(options.defaultMessage, node_os_1.EOL);
console.log(format_js_1.format.dim('Code: '), format_js_1.format.bold(format_js_1.format.fail(code)));
file && console.log(format_js_1.format.dim('File: '), file);
console.log(format_js_1.format.dim('Operator:'), operator);
(0, hr_js_1.hr)();
message = options.defaultMessage;
const finalMessage = (message === null || message === void 0 ? void 0 : message.trim().length) > 0
? `${formatFail(message)}`
: `${formatFail('No Message')}`;
console.log(isPoku
? `${finalMessage} ${format_js_1.format.dim(format_js_1.format.fail(`› ${FILE}`))}`
: finalMessage);
file && console.log(`${format_js_1.format.dim(' File')} ${file}`);
console.log(`${format_js_1.format.dim(' Code')} ${code}`);
console.log(`${format_js_1.format.dim(' Operator')} ${operator}${node_os_1.EOL}`);
if (!(options === null || options === void 0 ? void 0 : options.hideDiff)) {
console.log(format_js_1.format.dim(`${(options === null || options === void 0 ? void 0 : options.actual) || 'Actual'}:`));
console.log(format_js_1.format.dim(` ${(options === null || options === void 0 ? void 0 : options.actual) || 'Actual'}:`));
console.log(format_js_1.format.bold(typeof actual === 'function' || actual instanceof RegExp
? String(actual)
: format_js_1.format.fail(JSON.stringify(actual))));
console.log(`${node_os_1.EOL}${format_js_1.format.dim(`${(options === null || options === void 0 ? void 0 : options.expected) || 'Expected'}:`)}`);
console.log(format_js_1.format.bold(typeof expected === 'function' || expected instanceof RegExp
? String(expected)
: format_js_1.format.success(JSON.stringify(expected))));
(0, hr_js_1.hr)();
? ` ${String(actual)}`
: ` ${format_js_1.format.fail(JSON.stringify(actual))}`));
console.log(`${node_os_1.EOL} ${format_js_1.format.dim(`${(options === null || options === void 0 ? void 0 : options.expected) || 'Expected'}:`)}`);
console.log(format_js_1.format.bold(`${typeof expected === 'function' || expected instanceof RegExp
? ` ${String(expected)}`
: ` ${format_js_1.format.success(JSON.stringify(expected))}`}`));
}

@@ -61,0 +77,0 @@ if (options.throw) {

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

const parseAsssetion_js_1 = require("../helpers/parseAsssetion.js");
const format_js_1 = require("../helpers/format.js");
const ok = (value, message) => (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.ok(value), { message });

@@ -51,3 +50,3 @@ const equal = (actual, expected, message) => (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.equal(actual, expected), { message });

expected: 'RegExp',
defaultMessage: format_js_1.format.bold('Value should not match regExp'),
defaultMessage: 'Value should not match regExp',
});

@@ -67,3 +66,3 @@ function doesNotReject(block, errorOrMessage, message) {

message,
defaultMessage: format_js_1.format.bold('Got unwanted rejection'),
defaultMessage: 'Got unwanted rejection',
hideDiff: true,

@@ -83,3 +82,3 @@ throw: true,

message: typeof errorOrMessage === 'string' ? errorOrMessage : undefined,
defaultMessage: format_js_1.format.bold('Got unwanted rejection'),
defaultMessage: 'Got unwanted rejection',
hideDiff: true,

@@ -104,3 +103,3 @@ throw: true,

message: message,
defaultMessage: format_js_1.format.bold('Expected function not to throw'),
defaultMessage: 'Expected function not to throw',
hideDiff: true,

@@ -121,3 +120,3 @@ throw: true,

message: msg,
defaultMessage: format_js_1.format.bold('Expected function not to throw'),
defaultMessage: 'Expected function not to throw',
hideDiff: true,

@@ -141,3 +140,3 @@ throw: true,

message: message,
defaultMessage: format_js_1.format.bold('Expected function to throw'),
defaultMessage: 'Expected function to throw',
hideDiff: true,

@@ -157,3 +156,3 @@ });

message: msg,
defaultMessage: format_js_1.format.bold('Expected function to throw'),
defaultMessage: 'Expected function to throw',
hideDiff: true,

@@ -178,3 +177,3 @@ });

expected: 'RegExp',
defaultMessage: format_js_1.format.bold('Value should match regExp'),
defaultMessage: 'Value should match regExp',
});

@@ -189,3 +188,3 @@ const ifError = (value) => {

}, {
defaultMessage: format_js_1.format.bold('Expected no error, but received an error'),
defaultMessage: 'Expected no error, but received an error',
hideDiff: true,

@@ -205,3 +204,3 @@ throw: true,

message,
defaultMessage: format_js_1.format.bold('Test failed intentionally'),
defaultMessage: 'Test failed intentionally',
hideDiff: true,

@@ -224,3 +223,3 @@ });

message,
defaultMessage: format_js_1.format.bold('Expected promise to be rejected with specified error'),
defaultMessage: 'Expected promise to be rejected with specified error',
hideDiff: true,

@@ -240,3 +239,3 @@ });

message: msg,
defaultMessage: format_js_1.format.bold('Expected promise to be rejected'),
defaultMessage: 'Expected promise to be rejected',
hideDiff: true,

@@ -243,0 +242,0 @@ });

@@ -8,19 +8,20 @@ "use strict";

const node_process_1 = __importDefault(require("process"));
const node_os_1 = require("os");
const hr_js_1 = require("../helpers/hr.js");
const run_tests_js_1 = require("../services/run-tests.js");
const format_js_1 = require("../helpers/format.js");
const exit = (code, quiet) => {
const isPoku = run_tests_js_1.results.success > 0 || run_tests_js_1.results.fail > 0;
!quiet &&
node_process_1.default.on('exit', (code) => {
console.log(`Exited with code`, code, node_os_1.EOL);
isPoku &&
console.log(format_js_1.format.bg(42, `PASS › ${run_tests_js_1.results.success}`), format_js_1.format.bg(run_tests_js_1.results.fail === 0 ? 100 : 41, `FAIL › ${run_tests_js_1.results.fail}`));
isPoku && (0, hr_js_1.hr)();
console.log(`${format_js_1.format.dim('Exited with code')} ${format_js_1.format.bold(format_js_1.format === null || format_js_1.format === void 0 ? void 0 : format_js_1.format[code === 0 ? 'success' : 'fail'](String(code)))}`);
});
!quiet && (0, hr_js_1.hr)();
if (code !== 0) {
!quiet && console.log('Some tests failed.');
isPoku && !quiet && (0, hr_js_1.hr)();
if (code !== 0)
node_process_1.default.exit(1);
}
!quiet && console.log('All tests passed.');
node_process_1.default.exit(0);
};
exports.exit = exit;
node_process_1.default.stdout.on('resize', hr_js_1.hr);
node_process_1.default.on('unhandledRejection', (reason) => {

@@ -27,0 +28,0 @@ console.log('unhandledRejection', reason);

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

const currentFiles = node_fs_1.default.readdirSync(dirPath);
const defaultRegExp = /\.test\./i;
const defaultRegExp = /\.(test|spec)\./i;
const filter = (envFilter

@@ -32,2 +32,4 @@ ? envFilter

const fullPath = node_path_1.default.join(dirPath, file);
if (/node_modules/.test(fullPath))
continue;
if (exclude && exclude.some((regex) => regex.test(fullPath)))

@@ -34,0 +36,0 @@ continue;

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

exports.poku = void 0;
const node_os_1 = require("os");
const force_array_js_1 = require("../helpers/force-array.js");
const run_tests_js_1 = require("../services/run-tests.js");
const exit_js_1 = require("./exit.js");
const format_js_1 = require("../helpers/format.js");
const logs_js_1 = require("../helpers/logs.js");
const hr_js_1 = require("../helpers/hr.js");
const run_test_file_js_1 = require("../services/run-test-file.js");
const indentation_js_1 = require("../helpers/indentation.js");
function poku(targetDirs, configs) {
return __awaiter(this, void 0, void 0, function* () {
let code = 0;
const dirs = (0, force_array_js_1.forceArray)(targetDirs);
const prepareDirs = (0, force_array_js_1.forceArray)(targetDirs);
const dirs = prepareDirs.length > 0 ? prepareDirs : ['./'];
const showLogs = !(0, logs_js_1.isQuiet)(configs);
if (configs === null || configs === void 0 ? void 0 : configs.parallel) {
const results = yield Promise.all(dirs.map((dir) => (0, run_tests_js_1.runTestsParallel)(dir, configs)));
if (results.some((result) => !result))
if (showLogs) {
(0, hr_js_1.hr)();
console.log(`${format_js_1.format.bold('Running the Test Suite in Parallel')}${node_os_1.EOL}`);
}
const concurrency = yield Promise.all(dirs.map((dir) => (0, run_tests_js_1.runTestsParallel)(dir, configs)));
if (concurrency.some((result) => !result))
code = 1;
showLogs && (0, hr_js_1.hr)();
if (showLogs && run_test_file_js_1.fileResults.success.length > 0)
console.log(run_test_file_js_1.fileResults.success
.map((current) => `${indentation_js_1.indentation.test}${format_js_1.format.success('✔')} ${format_js_1.format.dim(current)}`)
.join(node_os_1.EOL));
if (showLogs && run_test_file_js_1.fileResults.fail.length > 0)
console.log(run_test_file_js_1.fileResults.fail
.map((current) => `${indentation_js_1.indentation.test}${format_js_1.format.fail('✘')} ${current}`)
.join(node_os_1.EOL));
if (configs === null || configs === void 0 ? void 0 : configs.noExit)

@@ -26,0 +47,0 @@ return code;

import { Configs } from '../@types/poku.js';
type FileResults = {
success: string[];
fail: string[];
};
export declare const fileResults: FileResults;
export declare const runTestFile: (filePath: string, configs?: Configs) => Promise<boolean>;
export {};

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.runTestFile = void 0;
exports.runTestFile = exports.fileResults = void 0;
const node_process_1 = __importDefault(require("process"));
const node_os_1 = require("os");
const node_path_1 = __importDefault(require("path"));
const node_child_process_1 = require("child_process");
const node_path_1 = __importDefault(require("path"));
const runner_js_1 = require("../helpers/runner.js");

@@ -15,32 +16,69 @@ const indentation_js_1 = require("../helpers/indentation.js");

const logs_js_1 = require("../helpers/logs.js");
const remove_repeats_js_1 = require("../helpers/remove-repeats.js");
exports.fileResults = {
success: [],
fail: [],
};
const runTestFile = (filePath, configs) => new Promise((resolve) => {
let output = '';
const showLogs = !(0, logs_js_1.isQuiet)(configs);
const showSuccess = (0, logs_js_1.showSuccesses)(configs);
const showFailure = (0, logs_js_1.showFailures)(configs);
const log = () => console.log(output === null || output === void 0 ? void 0 : output.trim());
const fileRelative = node_path_1.default.relative(node_process_1.default.cwd(), filePath);
showLogs &&
console.log(`${indentation_js_1.indentation.test}${format_js_1.format.info('→')} ${fileRelative}`);
const runtimeOptions = (0, runner_js_1.runner)(filePath, configs);
const runtime = runtimeOptions.shift();
const runtimeArguments = runtimeOptions.length > 1 ? [...runtimeOptions, filePath] : [filePath];
const fileRelative = node_path_1.default.relative(node_process_1.default.cwd(), filePath);
const showLogs = !(0, logs_js_1.isQuiet)(configs);
const showSuccess = (0, logs_js_1.isDebug)(configs);
const pad = (configs === null || configs === void 0 ? void 0 : configs.parallel) ? ' ' : ' ';
let output = '';
const log = () => {
const outputs = (0, remove_repeats_js_1.removeConsecutiveRepeats)(showSuccess
? output.split(/(\r\n|\r|\n)/)
: output.split(/(\r\n|\r|\n)/).filter((current) => {
if (current.includes('Exited with code'))
return false;
return (/u001b\[0m|(\r\n|\r|\n)/i.test(JSON.stringify(current)) ||
current === '');
}), /(\r\n|\r|\n)|^$/);
// Remove last EOL
outputs.length > 1 && outputs.pop();
if (!showSuccess &&
/error:/i.test(output) &&
!/error:/i.test(outputs.join()))
Object.assign(outputs, [
...outputs,
format_js_1.format.bold(format_js_1.format.fail(`✘ External Error ${format_js_1.format.dim(`› ${fileRelative}`)}`)),
format_js_1.format.dim(' For detailed diagnostics:'),
`${format_js_1.format.dim(` CLI ›`)} rerun with the ${format_js_1.format.bold('--debug')} flag enabled.`,
`${format_js_1.format.dim(` API ›`)} set the config option ${format_js_1.format.bold('debug')} to true.`,
`${format_js_1.format.dim(' RUN ›')} ${format_js_1.format.bold(`${runtime === 'tsx' ? 'npx tsx' : runtime}${runtimeArguments.slice(0, -1).join(' ')} ${fileRelative}`)}`,
]);
const mappedOutputs = outputs.map((current) => `${pad}${current}`);
if (outputs.length === 1 && outputs[0] === '')
return;
console.log(showSuccess ? mappedOutputs.join('') : mappedOutputs.join(node_os_1.EOL));
};
const stdOut = (data) => {
output += String(data);
};
if (!(configs === null || configs === void 0 ? void 0 : configs.parallel)) {
showLogs &&
console.log(`${indentation_js_1.indentation.test}${format_js_1.format.info(format_js_1.format.dim('●'))} ${format_js_1.format.dim(fileRelative)}`);
}
const child = (0, node_child_process_1.spawn)(runtime, runtimeArguments, {
stdio: ['inherit', 'pipe', 'pipe'],
env: node_process_1.default.env,
env: Object.assign(Object.assign({}, node_process_1.default.env), { FILE: (configs === null || configs === void 0 ? void 0 : configs.parallel) ? fileRelative : '' }),
});
child.stdout.on('data', (data) => {
output += data.toString();
});
child.stderr.on('data', (data) => {
output += data.toString();
});
child.stdout.on('data', stdOut);
child.stderr.on('data', stdOut);
child.on('close', (code) => {
if (showLogs &&
((code === 0 && showSuccess) || (code !== 0 && showFailure)))
if (showLogs)
log();
resolve(code === 0);
const result = code === 0;
if (result)
exports.fileResults.success.push(fileRelative);
else
exports.fileResults.fail.push(fileRelative);
resolve(result);
});
child.on('error', (err) => {
console.log(`Failed to start test: ${filePath}`, err);
exports.fileResults.fail.push(fileRelative);
resolve(false);

@@ -47,0 +85,0 @@ });

import { Configs } from '../@types/poku.js';
export declare const results: {
success: number;
fail: number;
};
export declare const runTests: (dir: string, configs?: Configs) => Promise<boolean>;
export declare const runTestsParallel: (dir: string, configs?: Configs) => Promise<boolean>;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.runTestsParallel = exports.runTests = void 0;
exports.runTestsParallel = exports.runTests = exports.results = void 0;
const node_process_1 = __importDefault(require("process"));

@@ -27,2 +27,6 @@ const node_os_1 = require("os");

const logs_js_1 = require("../helpers/logs.js");
exports.results = {
success: 0,
fail: 0,
};
const runTests = (dir, configs) => __awaiter(void 0, void 0, void 0, function* () {

@@ -38,3 +42,3 @@ const cwd = node_process_1.default.cwd();

(0, hr_js_1.hr)();
console.log(`${format_js_1.format.bold('Directory:')} ${format_js_1.format.underline(currentDir)}${node_os_1.EOL}`);
console.log(`${format_js_1.format.bold('Directory:')} ${format_js_1.format.underline(`./${currentDir}`)}${node_os_1.EOL}`);
}

@@ -49,9 +53,12 @@ for (let i = 0; i < files.length; i++) {

const nextLine = i + 1 !== files.length ? node_os_1.EOL : '';
const log = `${counter}/${totalTests} ${command}${nextLine}`;
const log = `${counter}/${totalTests} ${command}`;
if (testPassed) {
++exports.results.success;
showLogs &&
console.log(`${indentation_js_1.indentation.test}${format_js_1.format.success('✔')} ${log}`);
console.log(`${indentation_js_1.indentation.test}${format_js_1.format.success('✔')} ${log}`, nextLine);
}
else {
showLogs && console.log(`${indentation_js_1.indentation.test}${format_js_1.format.fail('✖')} ${log}`);
++exports.results.fail;
showLogs &&
console.log(`${indentation_js_1.indentation.test}${format_js_1.format.fail('✘')} ${log}`, nextLine);
passed = false;

@@ -67,21 +74,14 @@ }

const files = (0, list_files_js_1.listFiles)(testDir, undefined, configs);
const showLogs = !(0, logs_js_1.isQuiet)(configs);
const promises = files.map((filePath) => __awaiter(void 0, void 0, void 0, function* () {
const fileRelative = node_path_1.default.relative(cwd, filePath);
const testPassed = yield (0, run_test_file_js_1.runTestFile)(filePath, configs);
const command = `${(0, runner_js_1.runner)(fileRelative).join(' ')} ${fileRelative}`;
if (testPassed) {
showLogs &&
console.log(`${indentation_js_1.indentation.test}${format_js_1.format.success('✔')} ${command}`);
}
else {
showLogs &&
console.log(`${indentation_js_1.indentation.test}${format_js_1.format.fail('✖')} ${command}`);
if (!testPassed) {
++exports.results.fail;
return false;
}
++exports.results.success;
return true;
}));
const results = yield Promise.all(promises);
return results.every((result) => result);
const concurrency = yield Promise.all(promises);
return concurrency.every((result) => result);
});
exports.runTestsParallel = runTestsParallel;
{
"name": "poku",
"version": "1.4.0",
"version": "1.5.0",
"description": "🐷 Poku is your test runner pet for Node.js, Bun and Deno, combining flexibility, parallel and sequential runs, human-friendly assertion errors and high isolation level",

@@ -12,3 +12,2 @@ "main": "./lib/index.js",

"test:bun": "FILTER='bun-' npm run test:ci",
"update": "npx npu;",
"prebuild": "rm -rf ./lib ./ci",

@@ -19,4 +18,7 @@ "build": "npx tsc; npx tsc -p tsconfig.test.json",

"eslint:fix": "npx eslint . --fix --config ./.eslintrc.json",
"lint:checker": "npm run eslint:checker; npm run prettier:checker",
"lint:fix": "npm run eslint:fix; npm run prettier:fix",
"prettier:checker": "npx prettier --check .",
"prettier:fix": "npx prettier --write .github/workflows/*.yml ."
"prettier:fix": "npx prettier --write .github/workflows/*.yml .",
"update": "npx npu; npm i; npm run lint:fix; npm audit"
},

@@ -83,3 +85,4 @@ "license": "MIT",

"bun": ">=0.5.3",
"deno": ">=1.17.0"
"deno": ">=1.17.0",
"typescript": ">=5.0.2"
},

@@ -91,5 +94,5 @@ "files": [

"devDependencies": {
"@types/node": "^20.11.19",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"@types/node": "^20.11.20",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"eslint": "^8.56.0",

@@ -96,0 +99,0 @@ "eslint-config-prettier": "^9.1.0",

@@ -7,5 +7,4 @@ [node-version-url]: https://github.com/nodejs/node

[deno-version-image]: https://img.shields.io/badge/Deno->=1.30.0-70ffaf
[npm-image]: https://img.shields.io/npm/v/poku.svg?color=3dc1d3
[npm-url]: https://npmjs.org/package/poku
[typescript-url]: https://github.com/microsoft/TypeScript
[typescript-version-image]: https://img.shields.io/badge/TypeScript->=5.0.2-3077c6
[ci-url]: https://github.com/wellwelwel/poku/actions/workflows/ci.yml?query=branch%3Amain

@@ -15,4 +14,2 @@ [ci-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci.yml?event=push&style=flat&label=CI&branch=main

[ql-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/codeql.yml?event=push&style=flat&label=Code%20QL&branch=main
[license-url]: https://github.com/wellwelwel/poku/blob/main/LICENSE
[license-image]: https://img.shields.io/npm/l/poku.svg?maxAge=2592000&color=9c88ff

@@ -28,12 +25,11 @@ # Poku

[![Deno Version][deno-version-image]][deno-version-url]
[![NPM Version][npm-image]][npm-url]
[![License][license-image]][license-url]
[![TypeScript Version][typescript-version-image]][typescript-url]
[![GitHub Workflow Status (with event)][ci-image]][ci-url]
[![GitHub Workflow Status (with event)][ql-image]][ql-url]
Enjoying Poku? Consider giving him a star ⭐️
Enjoying **Poku**? Consider giving him a star ⭐️
---
🐷 [**Documentation Website**](https://poku.dev)
🐷 [**Documentation Website**](https://poku.dev) • 🔬 [**Compare Poku with the Most Popular Test Runners**](https://poku.dev/docs/comparing)

@@ -44,4 +40,6 @@ ---

> **Poku** starts from the premise where tests come to help, not overcomplicate: runs test files in an individual process per file, shows progress and exits 🧙🏻
Don't worry about `describe`, `it`, `beforeEach` and everything else 🚀
> You don't need to learn what you already know ✨
- Supports **ESM** and **CJS**

@@ -54,3 +52,3 @@ - Designed to be highly intuitive

- Zero configurations, except you want
- No constraints or rules, code in your own signature style
- Poku adapts to your test, not the other way around
- [**And much more!**](https://poku.dev)

@@ -60,4 +58,4 @@

- <img src="https://img.shields.io/bundlephobia/min/poku?label=Final%20Size">
- **Zero** external dependencies
- <img src="https://img.shields.io/bundlephobia/min/poku">
- **Zero** external dependencies 🌱

@@ -68,3 +66,3 @@ ---

- See detailed specifications and usage in [**Documentation**](https://poku.dev/docs/category/documentation) section for queries, advanced concepts and much more.
- See detailed usage in [**Documentation**](https://poku.dev/docs/category/documentation) section for **Poku**'s **CLI**, **API (_in-code_)** and **assert**, advanced concepts and much more.

@@ -75,14 +73,19 @@ ---

| Sequential | Parallel |
| ------------------------------------------------------------ | ---------------------------------------------------------- |
| `npx poku test/unit,test/integration` | `npx poku --parallel test/unit,test/integration` |
| <img src=".github/assets/readme/sequential.png" width="360"> | <img src=".github/assets/readme/parallel.png" width="360"> |
| Sequential | Concurrent |
| -------------------------------------------------- | ------------------------------------------------ |
| <img src=".github/assets/readme/sequential.png" /> | <img src=".github/assets/readme/parallel.png" /> |
- By default, **Poku** searches for all _`.test.`_ files, but you can customize it using the option [`filter`](https://github.com/wellwelwel/poku#filter-rexexp).
- The same idea for [**Bun**][bun-version-url] and [**Deno**][deno-version-url] (see bellow).
- By default, **Poku**:
- Searches for all _`.test.`_ and `.spec.` files, but you can customize it using the option [**`filter`**](https://poku.dev/docs/documentation/poku/configs/filter).
- Uses `sequential` mode.
- You can use concurrecy by use the flag `--parallel` for **CLI** or the option `parallel` to `true` in **API** (_in-code_) usage.
> Follow the same idea for [**Bun**][bun-version-url] and [**Deno**][deno-version-url].
---
**Poku** also includes the `assert` method, keeping everything as it is, but providing human readability:
**Poku** also includes the `assert` method, keeping everything as it is, but providing human readability and automatic `describe` and `it`:
> Compatible with **Node.js**, **Bun** and **Deno**.
```ts

@@ -92,8 +95,19 @@ import { assert } from 'poku'; // Node and Bun

assert(true);
assert.deepStrictEqual(1, '1', 'My optional custom message');
const actual = '1';
assert(actual, 'My first assert');
assert.deepStrictEqual(actual, 1, 'My first assert error');
```
> <img src=".github/assets/readme/assert.png" width="468" />
| Using `poku` | Using `node` |
| --------------------------------------------------- | --------------------------------------------------- |
| <img src=".github/assets/readme/assert-poku.png" /> | <img src=".github/assets/readme/assert-node.png" /> |
- ❌ Both cases finish with `code 1`, as expected
- 🧑🏻‍🎓 The `message` param is optional, as it's in **Node.js**
- 💚 Yes, you can use **Poku**'s `assert` running `node ./my-file.js`
- 🐷 Unlike most, **Poku** adapts to your test, not the other way around
> [**See the complete assert's documentation**](https://poku.dev/docs/documentation/assert).
---

@@ -105,6 +119,4 @@

> <img src=".github/assets/readme/node-js.svg" width="24" />
```bash
npm install --save-dev poku
npm i -D poku
```

@@ -114,8 +126,4 @@

> <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" />
```bash
npm install --save-dev poku tsx
npm i -D poku tsx
```

@@ -125,8 +133,4 @@

> <img src=".github/assets/readme/bun.svg" width="24" />
> <img src=".github/assets/readme/plus.svg" width="24" />
> <img src=".github/assets/readme/typescript.svg" width="24" />
```bash
bun add --dev poku
bun add -d poku
```

@@ -136,6 +140,2 @@

> <img src=".github/assets/readme/deno.svg" width="24" />
> <img src=".github/assets/readme/plus.svg" width="24" />
> <img src=".github/assets/readme/typescript.svg" width="24" />
```ts

@@ -145,4 +145,2 @@ import { poku } from 'npm:poku';

- **Poku** requires these permissions by default: `--allow-read`, `--allow-env` and `--allow-run`.
---

@@ -154,5 +152,3 @@

> <img src=".github/assets/readme/node-js.svg" width="24" />
> <img src=".github/assets/readme/plus.svg" width="24" />
> <img src=".github/assets/readme/bun.svg" width="24" />
#### Node.js and Bun

@@ -162,6 +158,6 @@ ```ts

await poku(['targetDirA', 'targetDirB']);
await poku(['targetDir']);
```
> <img src=".github/assets/readme/deno.svg" width="24" />
#### Deno

@@ -171,3 +167,3 @@ ```ts

await poku(['targetDirA', 'targetDirB']);
await poku(['targetDir']);
```

@@ -180,3 +176,3 @@

```bash
npx poku targetDirA,targetDirB
npx poku targetDir
```

@@ -187,3 +183,3 @@

```bash
bun poku targetDirA,targetDirB
bun poku targetDir
```

@@ -194,3 +190,3 @@

```bash
deno run npm:poku targetDirA,targetDirB
deno run npm:poku targetDir
```

@@ -197,0 +193,0 @@

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