Comparing version 1.11.0 to 1.12.0
@@ -60,2 +60,8 @@ import type { Configs as ListFilesConfigs } from './list-files.js'; | ||
/** | ||
* Limits the number of tests running concurrently. | ||
* | ||
* @default 0 | ||
*/ | ||
concurrency?: number; | ||
/** | ||
* You can use this option to run a **callback** or a **file** before each test file on your suite. | ||
@@ -62,0 +68,0 @@ * |
@@ -29,2 +29,3 @@ #! /usr/bin/env node | ||
const killPID = (0, get_arg_js_1.getArg)('kill-pid'); | ||
const concurrency = Number((0, get_arg_js_1.getArg)('concurrency')) || undefined; | ||
const parallel = (0, get_arg_js_1.hasArg)('parallel'); | ||
@@ -62,4 +63,5 @@ const quiet = (0, get_arg_js_1.hasArg)('quiet'); | ||
failFast, | ||
concurrency, | ||
}); | ||
}))(); | ||
/* c8 ignore stop */ |
@@ -76,18 +76,30 @@ "use strict"; | ||
const files = (0, list_files_js_1.isFile)(dir) ? [dir] : (0, list_files_js_1.listFiles)(testDir, undefined, configs); | ||
const filesByConcurrency = []; | ||
const concurrencyLimit = (configs === null || configs === void 0 ? void 0 : configs.concurrency) || 0; | ||
const concurrencyResults = []; | ||
if (concurrencyLimit > 0) | ||
for (let i = 0; i < files.length; i += concurrencyLimit) { | ||
filesByConcurrency.push(files.slice(i, i + concurrencyLimit)); | ||
} | ||
else | ||
filesByConcurrency.push(files); | ||
try { | ||
const promises = files.map((filePath) => __awaiter(void 0, void 0, void 0, function* () { | ||
if ((configs === null || configs === void 0 ? void 0 : configs.failFast) && exports.results.fail > 0) | ||
return; | ||
const testPassed = yield (0, run_test_file_js_1.runTestFile)(filePath, configs); | ||
if (!testPassed) { | ||
++exports.results.fail; | ||
if (configs === null || configs === void 0 ? void 0 : configs.failFast) | ||
throw ` ${format_js_1.format.fail('โน')} ${format_js_1.format.bold('fail-fast')} is enabled`; | ||
return false; | ||
} | ||
++exports.results.success; | ||
return true; | ||
})); | ||
const concurrency = yield Promise.all(promises); | ||
return concurrency.every((result) => result); | ||
for (const fileGroup of filesByConcurrency) { | ||
const promises = fileGroup.map((filePath) => __awaiter(void 0, void 0, void 0, function* () { | ||
if ((configs === null || configs === void 0 ? void 0 : configs.failFast) && exports.results.fail > 0) | ||
return; | ||
const testPassed = yield (0, run_test_file_js_1.runTestFile)(filePath, configs); | ||
if (!testPassed) { | ||
++exports.results.fail; | ||
if (configs === null || configs === void 0 ? void 0 : configs.failFast) | ||
throw ` ${format_js_1.format.fail('โน')} ${format_js_1.format.bold('fail-fast')} is enabled`; | ||
return false; | ||
} | ||
++exports.results.success; | ||
return true; | ||
})); | ||
const concurrency = yield Promise.all(promises); | ||
concurrencyResults.push(concurrency); | ||
} | ||
return concurrencyResults.every((group) => group.every((result) => result)); | ||
} | ||
@@ -94,0 +106,0 @@ catch (error) { |
{ | ||
"name": "poku", | ||
"version": "1.11.0", | ||
"version": "1.12.0", | ||
"description": "๐ท Poku makes testing easy for Node.js, Bun & Deno at the same time.", | ||
"main": "./lib/index.js", | ||
"scripts": { | ||
"test": "tsx src/bin/index.ts --parallel --debug --include=\"test/unit,test/integration,test/e2e\"", | ||
"test:bun": "bun src/bin/index.ts --parallel --platform=bun --debug --include=\"test/unit,test/integration,test/e2e\"", | ||
"test:c8": "c8 npm run test", | ||
"test": "tsx src/bin/index.ts --parallel --include=\"test/unit,test/integration,test/e2e\"", | ||
"test:options": " tsx src/bin/index.ts --parallel --concurrency=\"4\" --fast-fail --debug --exclude=\".bak\" --kill-port=\"4000\" --kill-range=\"4000-4001\" --include=\"test/unit,test/integration,test/e2e\"", | ||
"test:bun": "bun src/bin/index.ts --platform=bun --include=\"test/unit,test/integration,test/e2e\"", | ||
"test:c8:sequential": "c8 tsx src/bin/index.ts --include=\"test/unit,test/integration,test/e2e\"", | ||
"test:c8:parallel": "c8 tsx src/bin/index.ts --parallel --include=\"test/unit,test/integration,test/e2e\"", | ||
"test:c8:sequential:options": "c8 tsx src/bin/index.ts --fast-fail --debug --exclude=\".bak\" --kill-port=\"4000\" --kill-range=\"4000-4001\" --include=\"test/unit,test/integration,test/e2e\"", | ||
"test:c8:parallel:options": "c8 tsx src/bin/index.ts --parallel --concurrency=\"4\" --fast-fail --debug --exclude=\".bak\" --kill-port=\"4000\" --kill-range=\"4000-4001\" --include=\"test/unit,test/integration,test/e2e\"", | ||
"test:ci": "tsx ./test/ci.test.ts", | ||
@@ -108,5 +112,5 @@ "test:ci:node": "FILTER='node-' npm run test:ci", | ||
"devDependencies": { | ||
"@types/node": "^20.12.11", | ||
"@typescript-eslint/eslint-plugin": "^7.8.0", | ||
"@typescript-eslint/parser": "^7.8.0", | ||
"@types/node": "^20.12.12", | ||
"@typescript-eslint/eslint-plugin": "^7.9.0", | ||
"@typescript-eslint/parser": "^7.9.0", | ||
"c8": "^9.1.0", | ||
@@ -121,5 +125,5 @@ "eslint": "^8.57.0", | ||
"shx": "^0.3.4", | ||
"tsx": "4.2.1", | ||
"tsx": "4.10.4", | ||
"typescript": "^5.4.5" | ||
} | ||
} |
[node-version-url]: https://github.com/nodejs/node | ||
[node-version-image]: https://img.shields.io/badge/Node.js->=%206.0.0-badc58 | ||
[bun-version-url]: https://github.com/oven-sh/bun | ||
[bun-version-image]: https://img.shields.io/badge/Bun->=%200.5.3-f471b5 | ||
[deno-version-url]: https://github.com/denoland/deno | ||
[deno-version-image]: https://img.shields.io/badge/Deno->=%201.30.0-70ffaf | ||
[typescript-url]: https://github.com/microsoft/TypeScript | ||
[typescript-version-image]: https://img.shields.io/badge/TypeScript->=%204.7.2-3077c6 | ||
[ci-url]: https://github.com/wellwelwel/poku/actions/workflows/ci.yml?query=branch%3Amain | ||
[ci-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci.yml?event=push&style=flat&label=CI&branch=main | ||
[ql-url]: https://github.com/wellwelwel/poku/actions/workflows/codeql.yml?query=branch%3Amain | ||
[ql-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci-codeql.yml?event=push&style=flat&label=Code%20QL&branch=main | ||
[ci-linux-url]: https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-linux.yml?query=branch%3Amain | ||
[ci-linux-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-linux.yml?event=push&style=flat&label=&branch=main&logo=ubuntu&logoColor=white | ||
[ci-osx-url]: https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-osx.yml?query=branch%3Amain | ||
[ci-osx-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-osx.yml?event=push&style=flat&label=&branch=main&logo=apple&logoColor=white | ||
[ci-windows-url]: https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-linux.yml?query=branch%3Amain | ||
[ci-windows-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-linux.yml?event=push&style=flat&label=&branch=main&logo=windows&logoColor=white | ||
[ql-url]: https://github.com/wellwelwel/poku/actions/workflows/ci_codeql.yml?query=branch%3Amain | ||
[ql-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_codeql.yml?event=push&style=flat&label=&branch=main&logo=github&logoColor=white | ||
[coverage-image]: https://img.shields.io/codecov/c/github/wellwelwel/poku?label=Coverage | ||
[coverage-url]: https://app.codecov.io/github/wellwelwel/poku | ||
[downloads-image]: https://img.shields.io/npm/dt/poku.svg?&color=FFC312&label=Downloads | ||
[downloads-url]: https://npmjs.org/package/poku | ||
[downloads-image]: https://img.shields.io/npm/dt/poku.svg?&label=Downloads&logo=npm&logoColor=white&color=1e90ff | ||
[downloads-url]: https://www.npmjs.com/package/poku | ||
[license-url]: https://github.com/wellwelwel/poku/blob/main/LICENSE | ||
@@ -27,10 +27,8 @@ [license-image]: https://img.shields.io/npm/l/poku.svg?maxAge=2592000&color=9c88ff&label=License | ||
[![Node.js Version][node-version-image]][node-version-url] | ||
[![Bun Version][bun-version-image]][bun-version-url] | ||
[![Deno Version][deno-version-image]][deno-version-url] | ||
[![TypeScript Version][typescript-version-image]][typescript-url]<br /> | ||
[![GitHub Workflow Status (with event)][ci-image]][ci-url] | ||
[![GitHub Workflow Status (with event)][ql-image]][ql-url] | ||
[![GitHub Workflow Status (with event)][ci-linux-image]][ci-linux-url] | ||
[![GitHub Workflow Status (with event)][ci-osx-image]][ci-osx-url] | ||
[![GitHub Workflow Status (with event)][ci-windows-image]][ci-windows-url] | ||
[![GitHub Workflow Status (with event)][ql-image]][ql-url]<br /> | ||
[![NPM Downloads][downloads-image]][downloads-url] | ||
[![Coverage][coverage-image]][coverage-url] | ||
[![NPM Downloads][downloads-image]][downloads-url] | ||
[![License][license-image]][license-url] | ||
@@ -276,4 +274,4 @@ | ||
- **Poku** is still a bit lonely, without an **active community** around him, but we can change it ๐ค | ||
- Each file generates a sub-process during its execution. This can be reflected in projects with an extremely high volume of test files when run in parallel. | ||
- **Poku** community is gradually building up ๐ค | ||
- Although it has no external dependencies, **Poku** is not _all-in-one_, so it doesn't have features such as _mocks_ and _spies_, where you can use your favorite packages or native solutions. | ||
@@ -280,0 +278,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
119309
2320
298