Comparing version 2.2.4 to 2.3.0
@@ -20,2 +20,3 @@ #! /usr/bin/env node | ||
const options_js_1 = require("../parsers/options.js"); | ||
const cpus_js_1 = require("../polyfills/cpus.js"); | ||
(async () => { | ||
@@ -27,3 +28,4 @@ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; | ||
var _a; | ||
const includeArg = (0, get_arg_js_1.getArg)('include'); | ||
const includeArg = (0, get_arg_js_1.getArg)('include'); | ||
if (includeArg !== undefined) { | ||
@@ -42,2 +44,3 @@ return includeArg.split(','); | ||
const killPID = (0, get_arg_js_1.getArg)('kill-pid'); | ||
const denoAllow = (_c = (0, get_arg_js_1.argToArray)('deno-allow')) !== null && _c !== void 0 ? _c : (_d = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _d === void 0 ? void 0 : _d.allow; | ||
@@ -48,2 +51,3 @@ const denoDeny = (_e = (0, get_arg_js_1.argToArray)('deno-deny')) !== null && _e !== void 0 ? _e : (_f = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _f === void 0 ? void 0 : _f.deny; | ||
((_h = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _h === void 0 ? void 0 : _h.cjs); | ||
const parallel = (0, get_arg_js_1.hasArg)('parallel') || (0, get_arg_js_1.hasArg)('p', '-') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.parallel); | ||
@@ -66,2 +70,3 @@ const quiet = (0, get_arg_js_1.hasArg)('quiet') || (0, get_arg_js_1.hasArg)('q', '-') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.quiet); | ||
const tasks = []; | ||
if (killPort || ((_j = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _j === void 0 ? void 0 : _j.port)) { | ||
@@ -86,2 +91,3 @@ const ports = (killPort === null || killPort === void 0 ? void 0 : killPort.split(',').map(Number)) || ((_k = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _k === void 0 ? void 0 : _k.port) || []; | ||
} | ||
if (hasEnvFile || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.envFile)) { | ||
@@ -92,2 +98,3 @@ const envFilePath = (_r = (0, get_arg_js_1.getArg)('env-file')) !== null && _r !== void 0 ? _r : defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.envFile; | ||
const options = { | ||
platform: (0, get_runtime_js_1.platformIsValid)(platform) | ||
@@ -133,2 +140,3 @@ ? platform | ||
let isRunning = false; | ||
const listenStdin = (input) => { | ||
@@ -147,2 +155,3 @@ if (isRunning || executing.size > 0) { | ||
}; | ||
const resultsClear = () => { | ||
@@ -161,2 +170,3 @@ files_js_1.fileResults.success.clear(); | ||
if (watchMode) { | ||
node_process_1.default.stdin.removeListener('data', listenStdin); | ||
@@ -179,3 +189,6 @@ node_process_1.default.removeListener('SIGINT', poku_js_1.onSigint); | ||
} | ||
(0, poku_js_1.poku)(Array.from(tests), options).then(() => { | ||
(0, poku_js_1.poku)(Array.from(tests), { | ||
...options, | ||
concurrency: concurrency !== null && concurrency !== void 0 ? concurrency : Math.max(Math.floor((0, cpus_js_1.availableParallelism)() / 2), 1), | ||
}).then(() => { | ||
setTimeout(() => { | ||
@@ -209,2 +222,3 @@ executing.delete(filePath); | ||
write_js_1.Write.log(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`); | ||
node_process_1.default.stdin.setEncoding('utf-8'); | ||
@@ -211,0 +225,0 @@ node_process_1.default.stdin.on('data', listenStdin); |
export declare const results: { | ||
success: number; | ||
fail: number; | ||
skipped: number; | ||
skip: number; | ||
todo: number; | ||
}; |
@@ -7,3 +7,4 @@ "use strict"; | ||
fail: 0, | ||
skipped: 0, | ||
skip: 0, | ||
todo: 0, | ||
}; |
@@ -20,3 +20,2 @@ "use strict"; | ||
exports.onSigint = onSigint; | ||
node_process_1.default.once('SIGINT', exports.onSigint); | ||
@@ -27,4 +26,3 @@ async function poku(targetPaths, configs) { | ||
const start = node_process_1.default.hrtime(); | ||
const prepareDirs = Array.prototype.concat(targetPaths); | ||
const dirs = prepareDirs.length > 0 ? prepareDirs : ['.']; | ||
const dirs = Array.prototype.concat(targetPaths); | ||
const showLogs = !(0, output_js_1.isQuiet)(configs); | ||
@@ -50,3 +48,2 @@ | ||
(0, exit_js_1.exit)(code, configs === null || configs === void 0 ? void 0 : configs.quiet); | ||
return; | ||
} | ||
@@ -53,0 +50,0 @@ |
import type { DescribeOptions } from '../../@types/describe.js'; | ||
export declare function describe(title: string, cb: () => Promise<unknown>): Promise<void>; | ||
export declare function describe(title: string, cb: () => unknown): void; | ||
export declare function describe(cb: () => Promise<unknown>): Promise<void>; | ||
export declare function describe(cb: () => unknown): unknown; | ||
export declare function describe(title: string, options?: DescribeOptions): void; | ||
declare function describeCore(title: string, cb: () => Promise<unknown>): Promise<void>; | ||
declare function describeCore(title: string, cb: () => unknown): void; | ||
declare function describeCore(cb: () => Promise<unknown>): Promise<void>; | ||
declare function describeCore(cb: () => unknown): unknown; | ||
declare function describeCore(title: string, options?: DescribeOptions): void; | ||
export declare const describe: typeof describeCore & { | ||
todo: (message: string, _cb?: () => unknown) => void; | ||
}; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.describe = describe; | ||
exports.describe = void 0; | ||
const node_process_1 = require("process"); | ||
@@ -8,3 +8,4 @@ const format_js_1 = require("../../services/format.js"); | ||
const indentation_js_1 = require("../../configs/indentation.js"); | ||
async function describe(arg1, arg2) { | ||
const todo_js_1 = require("./it/todo.js"); | ||
async function describeCore(arg1, arg2) { | ||
let title; | ||
@@ -55,1 +56,4 @@ let cb; | ||
} | ||
exports.describe = Object.assign(describeCore, { | ||
todo: todo_js_1.todo, | ||
}); |
@@ -15,2 +15,26 @@ "use strict"; | ||
const isPoku = poku_js_1.results.success > 0 || poku_js_1.results.fail > 0; | ||
const success = ` PASS βΊ ${poku_js_1.results.success - poku_js_1.results.skip || 0} `; | ||
const failure = ` FAIL βΊ ${poku_js_1.results.fail} `; | ||
const skips = ` SKIP βΊ ${poku_js_1.results.skip} `; | ||
const plans = ` TODO βΊ ${poku_js_1.results.todo} `; | ||
const inline = poku_js_1.results.skip === 0 || poku_js_1.results.todo === 0; | ||
let message = ''; | ||
if (inline) { | ||
message += `${(0, format_js_1.format)(success).bg('green')} ${(0, format_js_1.format)(failure).bg(poku_js_1.results.fail === 0 ? 'grey' : 'brightRed')}`; | ||
if (poku_js_1.results.skip) { | ||
message += ` ${(0, format_js_1.format)(skips).bg('brightBlue')}`; | ||
} | ||
if (poku_js_1.results.todo) { | ||
message += ` ${(0, format_js_1.format)(plans).bg('brightBlue')}`; | ||
} | ||
} | ||
else { | ||
message += `${(0, format_js_1.format)(success).success().bold()}\n`; | ||
message += | ||
poku_js_1.results.fail === 0 | ||
? (0, format_js_1.format)(`${failure}\n`).bold() | ||
: `${(0, format_js_1.format)(failure).fail().bold()}\n`; | ||
message += `${(0, format_js_1.format)(skips).info().bold()}\n`; | ||
message += `${(0, format_js_1.format)(plans).info().bold()}`; | ||
} | ||
!quiet && | ||
@@ -24,3 +48,3 @@ node_process_1.default.on('exit', (code) => { | ||
write_js_1.Write.hr(); | ||
write_js_1.Write.log(`${(0, format_js_1.format)(` PASS βΊ ${poku_js_1.results.success - poku_js_1.results.skipped} `).bg('green')} ${(0, format_js_1.format)(` FAIL βΊ ${poku_js_1.results.fail} `).bg(poku_js_1.results.fail === 0 ? 'grey' : 'red')} ${poku_js_1.results.skipped > 0 ? (0, format_js_1.format)(` SKIPPED βΊ ${poku_js_1.results.skipped} `).bg(poku_js_1.results.skipped === 0 ? 'grey' : 'blue') : ''}`); | ||
write_js_1.Write.log(message); | ||
write_js_1.Write.hr(); | ||
@@ -27,0 +51,0 @@ } |
@@ -57,3 +57,3 @@ "use strict"; | ||
if (fullPath.indexOf('node_modules') !== -1 || | ||
fullPath.indexOf('.git') === 0) { | ||
fullPath.indexOf('.git/') !== -1) { | ||
return; | ||
@@ -60,0 +60,0 @@ } |
@@ -7,3 +7,3 @@ "use strict"; | ||
const format_js_1 = require("../../services/format.js"); | ||
const skip = (message) => { | ||
const skip = (message = 'Skipping') => { | ||
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; | ||
@@ -13,4 +13,4 @@ const FILE = node_process_1.env.FILE; | ||
write_js_1.Write.log((0, format_js_1.format)(isPoku | ||
? `βΉ ${message} ${(0, format_js_1.format)('βΊ').dim()} ${(0, format_js_1.format)(`${FILE}`).italic().gray().dim()}` | ||
: `βΉ ${message}`) | ||
? `β― ${message} ${(0, format_js_1.format)('βΊ').dim()} ${(0, format_js_1.format)(`${FILE}`).italic().gray().dim()}` | ||
: `β― ${message}`) | ||
.info() | ||
@@ -17,0 +17,0 @@ .bold()); |
@@ -1,2 +0,8 @@ | ||
import { it } from './it.js'; | ||
export declare const test: typeof it; | ||
export declare const test: { | ||
(message: string, cb: () => Promise<unknown>): Promise<void>; | ||
(message: string, cb: () => unknown): void; | ||
(cb: () => Promise<unknown>): Promise<void>; | ||
(cb: () => unknown): void; | ||
} & { | ||
todo: (message: string, _cb?: () => unknown) => void; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.test = void 0; | ||
const it_js_1 = require("./it.js"); | ||
exports.test = it_js_1.it; | ||
const core_js_1 = require("./it/core.js"); | ||
exports.test = core_js_1.it; |
@@ -7,3 +7,3 @@ import type { ConfigFile } from '../@types/poku.js'; | ||
export { describe } from './helpers/describe.js'; | ||
export { it } from './helpers/it.js'; | ||
export { it } from './helpers/it/core.js'; | ||
export { envFile } from './helpers/env.js'; | ||
@@ -10,0 +10,0 @@ export { skip } from './helpers/skip.js'; |
@@ -14,4 +14,4 @@ "use strict"; | ||
Object.defineProperty(exports, "describe", { enumerable: true, get: function () { return describe_js_1.describe; } }); | ||
var it_js_1 = require("./helpers/it.js"); | ||
Object.defineProperty(exports, "it", { enumerable: true, get: function () { return it_js_1.it; } }); | ||
var core_js_1 = require("./helpers/it/core.js"); | ||
Object.defineProperty(exports, "it", { enumerable: true, get: function () { return core_js_1.it; } }); | ||
var env_js_1 = require("./helpers/env.js"); | ||
@@ -18,0 +18,0 @@ Object.defineProperty(exports, "envFile", { enumerable: true, get: function () { return env_js_1.envFile; } }); |
@@ -8,3 +8,4 @@ "use strict"; | ||
ansi: /u001b\[0m|\n/i, | ||
skipped: /^"\\u001b\[94m\\u001b\[1mβΉ/i, | ||
skip: /\\u001b\[94m\\u001b\[1mβ―/i, | ||
todo: /\\u001b\[96m\\u001b\[1mβ/i, | ||
}; | ||
@@ -18,5 +19,8 @@ const isQuiet = (configs) => typeof (configs === null || configs === void 0 ? void 0 : configs.quiet) === 'boolean' && Boolean(configs === null || configs === void 0 ? void 0 : configs.quiet); | ||
const normalizedOutput = JSON.stringify(output); | ||
if (regex.skipped.test(normalizedOutput)) { | ||
++poku_js_1.results.skipped; | ||
if (regex.skip.test(normalizedOutput)) { | ||
++poku_js_1.results.skip; | ||
} | ||
if (regex.todo.test(normalizedOutput)) { | ||
++poku_js_1.results.todo; | ||
} | ||
const debug = (0, exports.isDebug)(configs); | ||
@@ -23,0 +27,0 @@ const pad = (configs === null || configs === void 0 ? void 0 : configs.parallel) ? ' ' : ' '; |
@@ -32,2 +32,3 @@ export declare const backgroundColor: { | ||
gray(): this; | ||
cyan(): this; | ||
bg(color: keyof typeof backgroundColor): this; | ||
@@ -34,0 +35,0 @@ [Symbol.toPrimitive](): string; |
@@ -70,2 +70,6 @@ "use strict"; | ||
} | ||
cyan() { | ||
this.parts += '\x1b[96m'; | ||
return this; | ||
} | ||
bg(color) { | ||
@@ -72,0 +76,0 @@ this.parts += `\x1b[${exports.backgroundColor[color]}m\x1b[1m`; |
@@ -68,3 +68,3 @@ "use strict"; | ||
const filesByConcurrency = []; | ||
const concurrencyLimit = (_a = configs === null || configs === void 0 ? void 0 : configs.concurrency) !== null && _a !== void 0 ? _a : Math.max(Math.floor((0, cpus_js_1.availableParallelism)() / 2), 1); | ||
const concurrencyLimit = (_a = configs === null || configs === void 0 ? void 0 : configs.concurrency) !== null && _a !== void 0 ? _a : Math.max((0, cpus_js_1.availableParallelism)() - 1, 1); | ||
const concurrencyResults = []; | ||
@@ -71,0 +71,0 @@ const showLogs = !(0, output_js_1.isQuiet)(configs); |
@@ -65,14 +65,11 @@ "use strict"; | ||
async start() { | ||
try { | ||
const stats = await (0, fs_js_1.stat)(this.rootDir); | ||
if (stats.isDirectory()) { | ||
this.files = await (0, list_files_js_1.listFiles)(this.rootDir); | ||
this.watchFiles(this.files); | ||
await this.watchDirectory(this.rootDir); | ||
} | ||
else { | ||
this.watchFile(this.rootDir); | ||
} | ||
const stats = await (0, fs_js_1.stat)(this.rootDir); | ||
if (stats.isDirectory()) { | ||
this.files = await (0, list_files_js_1.listFiles)(this.rootDir); | ||
this.watchFiles(this.files); | ||
await this.watchDirectory(this.rootDir); | ||
} | ||
catch (_a) { } | ||
else { | ||
this.watchFile(this.rootDir); | ||
} | ||
} | ||
@@ -79,0 +76,0 @@ stop() { |
{ | ||
"name": "poku", | ||
"version": "2.2.4", | ||
"version": "2.3.0", | ||
"description": "π· Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.", | ||
@@ -65,9 +65,9 @@ "main": "./lib/modules/index.js", | ||
"@biomejs/biome": "1.8.3", | ||
"@types/node": "^20.14.12", | ||
"@types/node": "^22.0.0", | ||
"c8": "^10.1.2", | ||
"jsonc.min": "^1.0.0", | ||
"monocart-coverage-reports": "^2.9.3", | ||
"monocart-coverage-reports": "^2.10.0", | ||
"packages-update": "^2.0.0", | ||
"prettier": "^3.3.3", | ||
"tsx": "4.16.2", | ||
"tsx": "4.16.3", | ||
"typescript": "^5.5.4" | ||
@@ -74,0 +74,0 @@ }, |
@@ -32,3 +32,3 @@ <div align="center"> | ||
<img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Run the **same test suite** for [**Node.js**][node-version-url], [**Bun**][bun-version-url], and [**Deno**][deno-version-url]<br /> | ||
<img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Easily handle **servers**, **processes**, **ports**, and **containers** β¨ | ||
<img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Easily handle **servers**, **processes**, **ports**, and even **containers** β¨ | ||
@@ -41,16 +41,39 @@ --- | ||
<table> | ||
<tr> | ||
<td width="225"> | ||
```bash | ||
# Node.js | ||
npm i -D poku | ||
``` | ||
</td> | ||
<td width="225"> | ||
```bash | ||
# TypeScript (Node.js) | ||
npm i -D poku tsx | ||
``` | ||
</td> | ||
<td width="225"> | ||
```bash | ||
# Bun | ||
bun add -d poku | ||
``` | ||
# Deno | ||
</td> | ||
<td width="225"> | ||
```bash | ||
# Deno (optional) | ||
deno add npm:poku | ||
``` | ||
</td> | ||
</tr> | ||
</table> | ||
--- | ||
@@ -225,4 +248,4 @@ | ||
- [Properly running asynchronous tests on the same file](https://poku.io/docs/examples/promises). | ||
- [Using **Poku** without installing on **Deno** and alternatives to **JSR**](https://github.com/wellwelwel/poku/discussions/565). | ||
- [Migrating from version **1.x** to version **2.x**](https://github.com/wellwelwel/poku/issues/533). | ||
- [Using **Poku** without installing on **Deno** and alternatives to **JSR**](https://github.com/wellwelwel/poku/discussions/565). | ||
@@ -237,5 +260,5 @@ --- | ||
- \>=**4x** faster than [**Jest**](https://github.com/jestjs/jest) (v29.7.0) | ||
- \>=**3x** faster than [**Vitest**](https://github.com/vitest-dev/vitest) (v1.6.0) | ||
- \>=**1x** faster than [**Mocha**](https://github.com/mochajs/mocha) (v10.4.0) + [**Chai**](https://github.com/chaijs/chai) (v5.1.1) | ||
- ~**4x** faster than [**Jest**](https://github.com/jestjs/jest) (v29.7.0) | ||
- ~**3x** faster than [**Vitest**](https://github.com/vitest-dev/vitest) (v1.6.0) | ||
- ~**1x** faster than [**Mocha**](https://github.com/mochajs/mocha) (v10.4.0) + [**Chai**](https://github.com/chaijs/chai) (v5.1.1) | ||
@@ -242,0 +265,0 @@ > You can see how the tests are run and compared in the [benchmark](https://github.com/wellwelwel/poku/tree/main/benchmark) directory. |
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
159887
109
3398
307