Comparing version 0.1.0 to 0.2.0
@@ -24,3 +24,3 @@ export type Configs = { | ||
/** | ||
* This option overwrites all `log` settings | ||
* This option overwrites all `log` settings. | ||
* | ||
@@ -31,3 +31,3 @@ * @default false | ||
/** | ||
* Filter by path to match only the files that should be performed | ||
* Filter by path to match only the files that should be performed. | ||
* | ||
@@ -37,3 +37,8 @@ * @default /\.test\./i | ||
filter?: RegExp; | ||
/** | ||
* Determines the mode of test execution. | ||
* | ||
* @default false | ||
*/ | ||
parallel?: boolean; | ||
}; |
@@ -21,13 +21,9 @@ "use strict"; | ||
if (configs === null || configs === void 0 ? void 0 : configs.parallel) { | ||
for (const dir of dirs) { | ||
(0, runTests_js_1.runTestsParallel)(dir, configs).then((result) => { | ||
if (!result) | ||
code = 1; | ||
}); | ||
const results = yield Promise.all(dirs.map((dir) => (0, runTests_js_1.runTestsParallel)(dir, configs))); | ||
if (results.some((result) => !result)) { | ||
code = 1; | ||
} | ||
process.on('beforeExit', () => { | ||
if (configs === null || configs === void 0 ? void 0 : configs.noExit) | ||
return code; | ||
(0, exit_js_1.exit)(code, configs === null || configs === void 0 ? void 0 : configs.quiet); | ||
}); | ||
if (configs === null || configs === void 0 ? void 0 : configs.noExit) | ||
return code; | ||
(0, exit_js_1.exit)(code, configs === null || configs === void 0 ? void 0 : configs.quiet); | ||
return; | ||
@@ -34,0 +30,0 @@ } |
import { Configs } from '../@types/poku.js'; | ||
export declare const runTests: (dir: string, configs?: Configs) => Promise<boolean>; | ||
export declare const runTestsParallel: (dir: string, configs?: Configs) => Promise<unknown>; | ||
export declare const runTestsParallel: (dir: string, configs?: Configs) => Promise<boolean>; |
@@ -58,3 +58,3 @@ "use strict"; | ||
exports.runTests = runTests; | ||
const runTestsParallel = (dir, configs) => { | ||
const runTestsParallel = (dir, configs) => __awaiter(void 0, void 0, void 0, function* () { | ||
const cwd = process.cwd(); | ||
@@ -64,24 +64,20 @@ const testDir = path_1.default.join(cwd, dir); | ||
const showLogs = !(0, logs_js_1.isQuiet)(configs); | ||
let passed = true; | ||
return new Promise((resolve) => { | ||
for (let i = 0; i < files.length; i++) { | ||
const filePath = files[i]; | ||
const fileRelative = path_1.default.relative(cwd, filePath); | ||
(0, runTestFile_js_1.runTestFile)(filePath, configs).then((testPassed) => { | ||
const command = `${(0, runner_js_1.runner)(fileRelative)} ${fileRelative}`; | ||
const log = command; | ||
if (testPassed) { | ||
showLogs && | ||
console.log(`${indentation_js_1.indentation.test}${format_js_1.format.success('✔')} ${log}`); | ||
} | ||
else { | ||
showLogs && | ||
console.log(`${indentation_js_1.indentation.test}${format_js_1.format.fail('✖')} ${log}`); | ||
passed = false; | ||
} | ||
}); | ||
resolve(passed); | ||
const promises = files.map((filePath) => __awaiter(void 0, void 0, void 0, function* () { | ||
const fileRelative = path_1.default.relative(cwd, filePath); | ||
const testPassed = yield (0, runTestFile_js_1.runTestFile)(filePath, configs); | ||
const command = `${(0, runner_js_1.runner)(fileRelative)} ${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}`); | ||
return false; | ||
} | ||
return true; | ||
})); | ||
const results = yield Promise.all(promises); | ||
return results.every((result) => result); | ||
}); | ||
exports.runTestsParallel = runTestsParallel; |
{ | ||
"name": "poku", | ||
"version": "0.1.0", | ||
"description": "🐷 This is Poku", | ||
"version": "0.2.0", | ||
"description": "🐷 A flexible and easy-to-use Test Runner for parallel and concurrent runs using high isolation level", | ||
"main": "./lib/index.js", | ||
@@ -15,2 +15,3 @@ "scripts": { | ||
"build": "npx tsc", | ||
"postbuild": "npm audit", | ||
"eslint:checker": "npx eslint . --ext .js,.ts", | ||
@@ -26,6 +27,20 @@ "eslint:fix": "npx eslint . --fix --config ./.eslintrc.json", | ||
}, | ||
"bin": { | ||
"poku": "./lib/bin/index.js" | ||
}, | ||
"keywords": [ | ||
"test", | ||
"testing", | ||
"runner", | ||
"isolate" | ||
"run", | ||
"isolate", | ||
"isolation", | ||
"concurrent", | ||
"parallel", | ||
"unit", | ||
"integration", | ||
"typescript", | ||
"filter", | ||
"queue", | ||
"queuing" | ||
], | ||
@@ -37,3 +52,3 @@ "author": "https://github.com/wellwelwel", | ||
"engines": { | ||
"node": ">=6.x" | ||
"node": ">=6.0.0" | ||
}, | ||
@@ -40,0 +55,0 @@ "files": [ |
@@ -0,1 +1,8 @@ | ||
[npm-image]: https://img.shields.io/npm/v/poku.svg?color=f78fb3 | ||
[npm-url]: https://npmjs.org/package/poku | ||
[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&color=badc58 | ||
[license-url]: https://github.com/wellwelwel/poku/blob/main/License | ||
[license-image]: https://img.shields.io/npm/l/poku.svg?maxAge=2592000&color=3dc1d3 | ||
# Poku | ||
@@ -5,15 +12,24 @@ | ||
🖇️ A flexible and user-friendly **Test Runner** which allows parallel runs and high isolation level. | ||
🖇️ A flexible and easy-to-use **Test Runner** for parallel or concurrent runs and high isolation level. | ||
> - **Poku** is designed to be highly intuitive.<br /> | ||
> - Compatible with **ESM** and **CJS**, **Node.js** and **TypeScript** (_no-build_).<br /> | ||
> - From **Node.js 6** to the **Latest** release.<br /> | ||
> - Totally dependency-free. | ||
[![NPM Version][npm-image]][npm-url] | ||
[![License][license-image]][license-url] | ||
[![GitHub Workflow Status (with event)][ci-image]][ci-url] | ||
--- | ||
## In progress | ||
## Why Poku? | ||
🧑🏻🔧 Soon releasing version `1.x`. | ||
> 🪄 Runs test files in an individual process, shows progress and exits.<br/> | ||
- **Poku** is designed to be highly intuitive.<br /> | ||
- Works with **Node.js 6** to **Latest** (_ESM_ and _CJS_), **TypeScript** (_no need to build_) and **Coverage** tools.<br /> | ||
- Poku dive to the deepest depths to find tests in the specified directories. | ||
- **Unleash creativity:** No constraints or predefined paths. Code in your own signature style. | ||
- **No environment restrictions:** **Poku** is strongly tested on all Node versions from **6** onwards. | ||
- As an example, **Poku** uses itself to test its own tests in different depths using several `process.exit` in the same node process. | ||
- Zero configurations, except you want. | ||
- Use both **in-code** and **CLI** usage. | ||
- Totally **dependency-free**. | ||
--- | ||
@@ -29,10 +45,16 @@ | ||
## Usage | ||
## Basic Usage | ||
## In-code | ||
```ts | ||
import { poku } from 'poku'; | ||
await poku(['./test/unit/']); | ||
await poku(['./a', './b']); | ||
``` | ||
// 🧑🏻🔧 Soon documenting all options and Poku's usage variations. | ||
### CLI | ||
```bash | ||
npx poku --include='./a,./b'; | ||
``` | ||
@@ -49,1 +71,8 @@ | ||
``` | ||
--- | ||
## In progress | ||
> 🧑🏻🔧 Soon releasing version `1.x`.<br /> | ||
> 🧑🏻🎓 Soon documenting all options and **Poku**'s usage variations. |
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
76
23419
41
421