poku 2.2.1 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,5 @@ export declare const indentation: {
2
2
  test: string;
3
3
  stdio: string;
4
4
  hasDescribe: boolean;
5
- hasTest: boolean;
6
- hasIt: boolean;
5
+ hasItOrTest: boolean;
7
6
  };
@@ -5,6 +5,5 @@ exports.indentation = {
5
5
  test: ' ',
6
6
  stdio: ' ',
7
7
  hasDescribe: false,
8
- hasTest: false,
9
- hasIt: false,
8
+ hasItOrTest: false,
10
9
  };
@@ -28,7 +28,6 @@ async function describe(arg1, arg2) {
28
28
  if (title) {
29
29
  indentation_js_1.indentation.hasDescribe = true;
30
30
  const { background, icon } = options || {};
31
- /* c8 ignore next */
32
31
  const message = `${cb ? (0, format_js_1.format)('◌').dim() : icon || '☰'} ${cb ? (0, format_js_1.format)(isPoku ? `${title} › ${(0, format_js_1.format)(`${FILE}`).italic().gray()}` : title).dim() : (0, format_js_1.format)(title).bold() || ''}`;
33
32
  const noBackground = !background;
34
33
  if (noBackground) {
@@ -9,45 +9,56 @@ const format_js_1 = require("../../services/format.js");
9
9
  const write_js_1 = require("../../services/write.js");
10
10
  /* c8 ignore next */ // ?
11
11
  async function it(...args) {
12
- let message;
13
- let cb;
14
- 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;
15
- const FILE = node_process_1.env.FILE;
16
- if (typeof args[0] === 'string') {
17
- message = args[0];
18
- cb = args[1];
19
- }
20
- else {
21
- cb = args[0];
22
- }
23
- if (message) {
24
- indentation_js_1.indentation.hasIt = true;
25
- write_js_1.Write.log(isPoku && !indentation_js_1.indentation.hasDescribe
26
- ? /* c8 ignore next 2 */
27
- `${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`◌ ${message} › ${(0, format_js_1.format)(`${FILE}`).italic().gray()}`).dim()}`
28
- : `${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`◌ ${message}`).dim()}`);
29
- }
30
- if (typeof each_js_1.each.before.cb === 'function') {
31
- const beforeResult = each_js_1.each.before.cb();
32
- if (beforeResult instanceof Promise) {
33
- await beforeResult;
12
+ try {
13
+ let message;
14
+ let cb;
15
+ 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;
16
+ const FILE = node_process_1.env.FILE;
17
+ if (typeof args[0] === 'string') {
18
+ message = args[0];
19
+ cb = args[1];
34
20
  }
35
- }
36
- const start = (0, node_process_1.hrtime)();
37
- const resultCb = cb();
38
- if (resultCb instanceof Promise) {
39
- await resultCb;
40
- }
41
- const end = (0, node_process_1.hrtime)(start);
42
- if (typeof each_js_1.each.after.cb === 'function') {
43
- const afterResult = each_js_1.each.after.cb();
44
- if (afterResult instanceof Promise) {
45
- await afterResult;
21
+ else {
22
+ cb = args[0];
23
+ }
24
+ if (message) {
25
+ indentation_js_1.indentation.hasItOrTest = true;
26
+ write_js_1.Write.log(isPoku && !indentation_js_1.indentation.hasDescribe
27
+ ? `${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`◌ ${message} › ${(0, format_js_1.format)(`${FILE}`).italic().gray()}`).dim()}`
28
+ : `${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`◌ ${message}`).dim()}`);
29
+ }
30
+ if (typeof each_js_1.each.before.cb === 'function') {
31
+ const beforeResult = each_js_1.each.before.cb();
32
+ if (beforeResult instanceof Promise) {
33
+ await beforeResult;
34
+ }
35
+ }
36
+ const start = (0, node_process_1.hrtime)();
37
+ const resultCb = cb();
38
+ if (resultCb instanceof Promise) {
39
+ await resultCb;
40
+ }
41
+ const end = (0, node_process_1.hrtime)(start);
42
+ if (typeof each_js_1.each.after.cb === 'function') {
43
+ const afterResult = each_js_1.each.after.cb();
44
+ if (afterResult instanceof Promise) {
45
+ await afterResult;
46
+ }
47
+ }
48
+ if (message) {
49
+ const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
50
+ indentation_js_1.indentation.hasItOrTest = false;
51
+ write_js_1.Write.log(`${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`● ${message}`).success().bold()} ${(0, format_js_1.format)(`› ${total}ms`).success().dim()}`);
46
52
  }
47
53
  }
48
- if (message) {
49
- const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
50
- indentation_js_1.indentation.hasIt = false;
51
- write_js_1.Write.log(`${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`● ${message}`).success().bold()} ${(0, format_js_1.format)(`› ${total}ms`).success().dim()}`);
54
+ catch (error) {
55
+ indentation_js_1.indentation.hasItOrTest = false;
56
+ if (typeof each_js_1.each.after.cb === 'function') {
57
+ const afterResult = each_js_1.each.after.cb();
58
+ if (afterResult instanceof Promise) {
59
+ await afterResult;
60
+ }
61
+ }
62
+ throw error;
52
63
  }
53
64
  }
@@ -1,4 +1,2 @@
1
- export declare function test(message: string, cb: () => Promise<unknown>): Promise<void>;
2
- export declare function test(message: string, cb: () => unknown): void;
3
- export declare function test(cb: () => Promise<unknown>): Promise<void>;
4
- export declare function test(cb: () => unknown): void;
1
+ import { it } from './it.js';
2
+ export declare const test: typeof it;
@@ -1,53 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.test = test;
3
+ exports.test = void 0;
4
4
  /* c8 ignore next */ // ?
5
- const node_process_1 = require("process");
6
- const each_js_1 = require("../../configs/each.js");
7
- const indentation_js_1 = require("../../configs/indentation.js");
8
- const format_js_1 = require("../../services/format.js");
9
- const write_js_1 = require("../../services/write.js");
5
+ const it_js_1 = require("./it.js");
10
6
  /* c8 ignore next */ // ?
11
- async function test(...args) {
12
- let message;
13
- let cb;
14
- 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;
15
- const FILE = node_process_1.env.FILE;
16
- if (typeof args[0] === 'string') {
17
- message = args[0];
18
- cb = args[1];
19
- }
20
- else {
21
- cb = args[0];
22
- }
23
- if (message) {
24
- indentation_js_1.indentation.hasTest = true;
25
- write_js_1.Write.log(isPoku
26
- ? /* c8 ignore next 2 */
27
- (0, format_js_1.format)(`◌ ${message} › ${(0, format_js_1.format)(`${FILE}`).italic().gray()}`).dim()
28
- : (0, format_js_1.format)(`◌ ${message}`).dim());
29
- }
30
- if (typeof each_js_1.each.before.cb === 'function') {
31
- const beforeResult = each_js_1.each.before.cb();
32
- if (beforeResult instanceof Promise) {
33
- await beforeResult;
34
- }
35
- }
36
- const start = (0, node_process_1.hrtime)();
37
- const resultCb = cb();
38
- if (resultCb instanceof Promise) {
39
- await resultCb;
40
- }
41
- const end = (0, node_process_1.hrtime)(start);
42
- if (typeof each_js_1.each.after.cb === 'function') {
43
- const afterResult = each_js_1.each.after.cb();
44
- if (afterResult instanceof Promise) {
45
- await afterResult;
46
- }
47
- }
48
- if (message) {
49
- const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
50
- indentation_js_1.indentation.hasTest = false;
51
- write_js_1.Write.log(`${(0, format_js_1.format)(`● ${message}`).success().bold()} ${(0, format_js_1.format)(`› ${total}ms`).success().dim()}`);
52
- }
53
- }
7
+ exports.test = it_js_1.it;
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.getConfigs = void 0;
27
4
  const node_process_1 = require("process");
@@ -43,8 +20,7 @@ const getConfigs = async (customPath) => {
43
20
  const filePath = (0, node_path_1.join)(processCWD, file);
44
21
  try {
45
22
  if (filePath.endsWith('.js') || filePath.endsWith('.cjs')) {
46
- /* c8 ignore next */ // ?
47
- return (await Promise.resolve(`${(0, node_path_1.normalize)(filePath)}`).then(s => __importStar(require(s))));
23
+ return require(`file://${(0, node_path_1.normalize)(filePath)}`);
48
24
  }
49
25
  const configsFile = await (0, fs_js_1.readFile)(filePath, 'utf-8');
50
26
  return jsonc_js_1.JSONC.parse(configsFile);
@@ -0,0 +1 @@
1
+ export declare const availableParallelism: () => number;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.availableParallelism = void 0;
4
+ const node_os_1 = require("os");
5
+ const availableParallelism = () => {
6
+ var _a, _b;
7
+ return typeof node_os_1.availableParallelism === 'function'
8
+ ? Math.floor((0, node_os_1.availableParallelism)() / 2)
9
+ : ((_b = (_a = (0, node_os_1.cpus)()) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 1);
10
+ };
11
+ exports.availableParallelism = availableParallelism;
@@ -19,10 +19,10 @@ const processAssert = async (cb, options) => {
19
19
  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;
20
20
  const FILE = node_process_1.env.FILE;
21
21
  let preIdentation = '';
22
- if (indentation_js_1.indentation.hasDescribe || indentation_js_1.indentation.hasTest) {
22
+ if (indentation_js_1.indentation.hasDescribe) {
23
23
  preIdentation += ' ';
24
24
  }
25
- if (indentation_js_1.indentation.hasIt) {
25
+ if (indentation_js_1.indentation.hasItOrTest) {
26
26
  preIdentation += ' ';
27
27
  }
28
28
  try {
@@ -31,11 +31,7 @@ const processAssert = async (cb, options) => {
31
31
  await cbResult;
32
32
  }
33
33
  if (typeof options.message === 'string') {
34
- const message = isPoku &&
35
- !indentation_js_1.indentation.hasDescribe &&
36
- !indentation_js_1.indentation.hasIt &&
37
- /* c8 ignore next 2 */
38
- !indentation_js_1.indentation.hasTest
34
+ const message = isPoku && !indentation_js_1.indentation.hasDescribe && !indentation_js_1.indentation.hasItOrTest
39
35
  ? `${preIdentation}${(0, format_js_1.format)(`${(0, format_js_1.format)(`✔ ${options.message}`).bold()} ${(0, format_js_1.format)(`› ${FILE}`).success().dim()}`).success()}`
40
36
  : `${preIdentation}${(0, format_js_1.format)(`✔ ${options.message}`).success().bold()}`;
41
37
  write_js_1.Write.log(message);
@@ -45,8 +41,8 @@ const processAssert = async (cb, options) => {
45
41
  catch (error) {
46
42
  if (error instanceof node_assert_1.AssertionError) {
47
43
  const { code, actual, expected, operator } = error;
48
- const absoultePath = (0, find_file_from_stack_js_1.findFile)(error).replace(regexFile, '');
49
- const file = node_path_1.default.relative(node_path_1.default.resolve(cwd), absoultePath);
44
+ const absolutePath = (0, find_file_from_stack_js_1.findFile)(error).replace(regexFile, '');
45
+ const file = node_path_1.default.relative(node_path_1.default.resolve(cwd), absolutePath);
50
46
  let message = '';
51
47
  if (typeof options.message === 'string') {
52
48
  message = options.message;
@@ -59,7 +55,7 @@ const processAssert = async (cb, options) => {
59
55
  }
60
56
  const finalMessage = (message === null || message === void 0 ? void 0 : message.trim().length) > 0
61
57
  ? (0, format_js_1.format)(`✘ ${message}`).fail().bold()
62
- : (0, format_js_1.format)('✘ No Message').fail().bold();
58
+ : (0, format_js_1.format)('✘ Assertion Error').fail().bold();
63
59
  write_js_1.Write.log(isPoku
64
60
  ? `${preIdentation}${finalMessage} ${(0, format_js_1.format)(`› ${FILE}`).fail().dim()}`
65
61
  : `${preIdentation}${finalMessage}`);
@@ -88,7 +84,6 @@ const processAssert = async (cb, options) => {
88
84
  // Non-assertion errors
89
85
  throw error;
90
86
  }
91
- /* c8 ignore stop */
92
87
  };
93
88
  exports.processAssert = processAssert;
94
89
  /* c8 ignore next */ // ?
@@ -11,6 +11,7 @@ const format_js_1 = require("./format.js");
11
11
  const run_test_file_js_1 = require("./run-test-file.js");
12
12
  const output_js_1 = require("../parsers/output.js");
13
13
  const poku_js_1 = require("../configs/poku.js");
14
+ const cpus_js_1 = require("../polyfills/cpus.js");
14
15
  const cwd = (0, node_process_1.cwd)();
15
16
  const runTests = async (dir, configs) => {
16
17
  const testDir = (0, node_path_1.join)(cwd, dir);
@@ -65,12 +66,13 @@ const runTests = async (dir, configs) => {
65
66
  exports.runTests = runTests;
66
67
  /* c8 ignore next */ // ?
67
68
  const runTestsParallel = async (dir, configs) => {
69
+ var _a;
68
70
  const testDir = (0, node_path_1.join)(cwd, dir);
69
71
  const files = (await (0, list_files_js_1.isFile)(dir))
70
72
  ? [(0, list_files_js_1.sanitizePath)(dir)]
71
73
  : await (0, list_files_js_1.listFiles)(testDir, configs);
72
74
  const filesByConcurrency = [];
73
- const concurrencyLimit = (configs === null || configs === void 0 ? void 0 : configs.concurrency) || 0;
75
+ const concurrencyLimit = (_a = configs === null || configs === void 0 ? void 0 : configs.concurrency) !== null && _a !== void 0 ? _a : (0, cpus_js_1.availableParallelism)();
74
76
  const concurrencyResults = [];
75
77
  const showLogs = !(0, output_js_1.isQuiet)(configs);
76
78
  if (concurrencyLimit > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poku",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "🐷 Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.",
5
5
  "main": "./lib/modules/index.js",
6
6
  "license": "MIT",
@@ -60,7 +60,7 @@
60
60
  },
61
61
  "devDependencies": {
62
62
  "@biomejs/biome": "1.8.3",
63
- "@types/node": "^20.14.11",
63
+ "@types/node": "^20.14.12",
64
64
  "c8": "^10.1.2",
65
65
  "packages-update": "^2.0.0",
66
66
  "prettier": "^3.3.3",