Comparing version 1.9.4 to 1.10.0
@@ -54,2 +54,8 @@ import type { Configs as ListFilesConfigs } from './list-files.js'; | ||
/** | ||
* Stops the tests at the first failure. | ||
* | ||
* @default false | ||
*/ | ||
failFast?: boolean; | ||
/** | ||
* You can use this option to run a **callback** or a **file** before each test file on your suite. | ||
@@ -56,0 +62,0 @@ * |
@@ -20,2 +20,3 @@ #! /usr/bin/env node | ||
const debug = (0, get_arg_js_1.hasArg)('debug'); | ||
const failFast = (0, get_arg_js_1.hasArg)('fail-fast'); | ||
if ((0, get_arg_js_1.hasArg)('log-success')) | ||
@@ -30,3 +31,4 @@ console.log(`The flag ${format_js_1.format.bold('--log-success')} is deprecated. Use ${format_js_1.format.bold('--debug')} instead.`); | ||
debug, | ||
failFast, | ||
}); | ||
/* c8 ignore stop */ |
@@ -16,11 +16,10 @@ "use strict"; | ||
node_process_1.default.on('exit', (code) => { | ||
isPoku && | ||
if (isPoku) { | ||
(0, hr_js_1.hr)(); | ||
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)(); | ||
(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)))}`); | ||
}); | ||
isPoku && !quiet && (0, hr_js_1.hr)(); | ||
if (code !== 0) | ||
node_process_1.default.exit(1); | ||
node_process_1.default.exit(0); | ||
node_process_1.default.exit(code === 0 ? 0 : 1); | ||
}; | ||
@@ -27,0 +26,0 @@ exports.exit = exit; |
@@ -32,19 +32,12 @@ "use strict"; | ||
const showLogs = !(0, logs_js_1.isQuiet)(configs); | ||
if (configs === null || configs === void 0 ? void 0 : configs.parallel) { | ||
if (showLogs) { | ||
(0, hr_js_1.hr)(); | ||
console.log(`${format_js_1.format.bold('Running the Test Suite in Parallel')}${node_os_1.EOL}`); | ||
// Sequential | ||
if (!(configs === null || configs === void 0 ? void 0 : configs.parallel)) { | ||
for (const dir of dirs) { | ||
const result = yield (0, run_tests_js_1.runTests)(dir, configs); | ||
if (!result) { | ||
code = 1; | ||
if (configs === null || configs === void 0 ? void 0 : configs.failFast) | ||
break; | ||
} | ||
} | ||
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) | ||
@@ -55,7 +48,28 @@ return code; | ||
} | ||
for (const dir of dirs) { | ||
const result = yield (0, run_tests_js_1.runTests)(dir, configs); | ||
if (!result) | ||
// Parallel | ||
if (showLogs) { | ||
(0, hr_js_1.hr)(); | ||
console.log(`${format_js_1.format.bold('Running the Test Suite in Parallel')}${node_os_1.EOL}`); | ||
} | ||
try { | ||
const promises = dirs.map((dir) => __awaiter(this, void 0, void 0, function* () { | ||
const result = yield (0, run_tests_js_1.runTestsParallel)(dir, configs); | ||
if (!result && (configs === null || configs === void 0 ? void 0 : configs.failFast)) | ||
throw ''; | ||
return result; | ||
})); | ||
const concurrency = yield Promise.all(promises); | ||
if (concurrency.some((result) => !result)) | ||
code = 1; | ||
} | ||
catch (_a) { } | ||
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) | ||
@@ -62,0 +76,0 @@ return code; |
@@ -62,2 +62,7 @@ "use strict"; | ||
passed = false; | ||
if (configs === null || configs === void 0 ? void 0 : configs.failFast) { | ||
(0, hr_js_1.hr)(); | ||
console.log(` ${format_js_1.format.fail('ℹ')} ${format_js_1.format.bold('fail-fast')} is enabled`); | ||
break; | ||
} | ||
} | ||
@@ -72,14 +77,25 @@ } | ||
const files = (0, list_files_js_1.isFile)(dir) ? [dir] : (0, list_files_js_1.listFiles)(testDir, undefined, configs); | ||
const promises = files.map((filePath) => __awaiter(void 0, void 0, void 0, function* () { | ||
const testPassed = yield (0, run_test_file_js_1.runTestFile)(filePath, configs); | ||
if (!testPassed) { | ||
++exports.results.fail; | ||
return false; | ||
} | ||
++exports.results.success; | ||
return true; | ||
})); | ||
const concurrency = yield Promise.all(promises); | ||
return concurrency.every((result) => result); | ||
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); | ||
} | ||
catch (error) { | ||
(0, hr_js_1.hr)(); | ||
console.log(error); | ||
return false; | ||
} | ||
}); | ||
exports.runTestsParallel = runTestsParallel; |
{ | ||
"name": "poku", | ||
"version": "1.9.4", | ||
"version": "1.10.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 test/unit,test/integration,test/e2e", | ||
"test": "tsx src/bin/index.ts --parallel --debug --include=\"test/unit,test/integration,test/e2e\"", | ||
"test:c8": "c8 npm run test", | ||
@@ -25,3 +25,3 @@ "test:ci": "tsx ./test/ci.test.ts", | ||
"prettier:fix": "prettier --write .github/workflows/*.yml .", | ||
"update": "npu && npm i && npm run lint:fix && npm audit" | ||
"update": "npu --minor && npm i && npm run lint:fix && npm audit" | ||
}, | ||
@@ -106,5 +106,5 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@types/node": "^20.12.7", | ||
"@typescript-eslint/eslint-plugin": "^7.7.1", | ||
"@typescript-eslint/parser": "^7.7.1", | ||
"@types/node": "^20.12.11", | ||
"@typescript-eslint/eslint-plugin": "^7.8.0", | ||
"@typescript-eslint/parser": "^7.8.0", | ||
"c8": "^9.1.0", | ||
@@ -111,0 +111,0 @@ "eslint": "^8.57.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
106717
2053