kizu 3.9.2-next.1 → 3.9.2-next.2
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.
- package/README.md +22 -0
- package/bin/cli.js +16 -3
- package/dist/workerPool.js +20 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,6 +36,7 @@ Designed to help you write simple, readable, and maintainable tests.
|
|
|
36
36
|
|
|
37
37
|
### **🔒 Out-of-the-box Typescript support**
|
|
38
38
|
- No special configuration needed, and no plugins to install.
|
|
39
|
+
- Automatically detects and uses your project's TypeScript runtime (`tsx` recommended, `ts-node` fallback).
|
|
39
40
|
- Works great with [c8](https://github.com/bcoe/c8) for code coverage.
|
|
40
41
|
- Handles compilation errors gracefully.
|
|
41
42
|
|
|
@@ -53,6 +54,27 @@ Note: `assert.equal()` compares values by value (deep equality), not by referenc
|
|
|
53
54
|
|
|
54
55
|
This single assertion method eliminates the need for multiple specialized assertion methods or complex mocking while providing powerful, flexible testing capabilities.
|
|
55
56
|
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm install --save-dev kizu
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### TypeScript Support
|
|
64
|
+
|
|
65
|
+
For TypeScript files, kizu automatically detects and uses your project's TypeScript runtime:
|
|
66
|
+
|
|
67
|
+
- **Recommended**: `tsx` (faster)
|
|
68
|
+
```bash
|
|
69
|
+
npm install --save-dev tsx
|
|
70
|
+
```
|
|
71
|
+
- **Fallback**: `ts-node`
|
|
72
|
+
```bash
|
|
73
|
+
npm install --save-dev ts-node
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
kizu will automatically use whichever is available, preferring `tsx` for better performance.
|
|
77
|
+
|
|
56
78
|
## Quick Examples
|
|
57
79
|
|
|
58
80
|
For more examples, see the [examples](examples) and [src](src) folders.
|
package/bin/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// Universal CLI entry point that works with both CJS and ESM
|
|
4
|
-
// and automatically handles TypeScript files using tsx
|
|
4
|
+
// and automatically handles TypeScript files using tsx (with ts-node fallback)
|
|
5
5
|
|
|
6
6
|
const { existsSync } = require('fs');
|
|
7
7
|
const { resolve } = require('path');
|
|
@@ -19,8 +19,21 @@ if (existsSync(cjsCliPath)) {
|
|
|
19
19
|
const { runCLI } = require(esmCliPath);
|
|
20
20
|
runCLI();
|
|
21
21
|
} else {
|
|
22
|
-
// Development mode -
|
|
23
|
-
|
|
22
|
+
// Development mode - try tsx first, fallback to ts-node
|
|
23
|
+
try {
|
|
24
|
+
require('tsx/cjs');
|
|
25
|
+
} catch (error) {
|
|
26
|
+
try {
|
|
27
|
+
// Fallback to ts-node if tsx is not available
|
|
28
|
+
require('ts-node/register');
|
|
29
|
+
} catch (error) {
|
|
30
|
+
// No TypeScript runtime available
|
|
31
|
+
console.error('Error: No TypeScript runtime found. Please install either:');
|
|
32
|
+
console.error(' npm install --save-dev tsx (recommended, faster)');
|
|
33
|
+
console.error(' npm install --save-dev ts-node');
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
24
37
|
const { runCLI } = require('../src/cli');
|
|
25
38
|
runCLI();
|
|
26
39
|
}
|
package/dist/workerPool.js
CHANGED
|
@@ -8,6 +8,24 @@ const path_1 = require("path");
|
|
|
8
8
|
const numCores = (0, os_1.cpus)().length; // will be the size of our worker pool
|
|
9
9
|
let numWorkers = 0;
|
|
10
10
|
let currentSpecFileIndex = 0;
|
|
11
|
+
function getTypeScriptRuntime() {
|
|
12
|
+
try {
|
|
13
|
+
// Try to use tsx first (much faster)
|
|
14
|
+
require.resolve('tsx/cjs');
|
|
15
|
+
return ['-r', 'tsx/cjs'];
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
try {
|
|
19
|
+
// Fallback to ts-node if tsx is not available
|
|
20
|
+
require.resolve('ts-node/register');
|
|
21
|
+
return ['-r', 'ts-node/register'];
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
// No TypeScript runtime available
|
|
25
|
+
throw new Error('No TypeScript runtime found. Please install either:\n npm install --save-dev tsx (recommended, faster)\n npm install --save-dev ts-node');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
11
29
|
function workerPool(specFiles, addTestResults) {
|
|
12
30
|
return new Promise((resolve, reject) => {
|
|
13
31
|
function next() {
|
|
@@ -18,9 +36,9 @@ function workerPool(specFiles, addTestResults) {
|
|
|
18
36
|
if (numWorkers >= numCores)
|
|
19
37
|
return;
|
|
20
38
|
const file = specFiles[currentSpecFileIndex];
|
|
21
|
-
// Use tsx for TypeScript files (faster than ts-node),
|
|
39
|
+
// Use tsx for TypeScript files (faster than ts-node), fallback to ts-node if not available
|
|
22
40
|
const isTypeScript = (0, path_1.extname)(file) === '.ts';
|
|
23
|
-
const execArgv = isTypeScript ?
|
|
41
|
+
const execArgv = isTypeScript ? getTypeScriptRuntime() : [];
|
|
24
42
|
const [err, worker] = (0, toResult_1.toResult)(() => (0, child_process_1.fork)(file, [], { execArgv }));
|
|
25
43
|
if (err) {
|
|
26
44
|
return reject(new Error(`failed to create worker for ${file}`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kizu",
|
|
3
|
-
"version": "3.9.2-next.
|
|
3
|
+
"version": "3.9.2-next.2",
|
|
4
4
|
"description": "An easy-to-use, fast, and defensive Typescript/Javascript test runner designed to help you to write simple, readable, and maintainable tests.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|