kizu 4.0.0 → 5.0.0

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.
Files changed (2) hide show
  1. package/README.md +11 -139
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -40,96 +40,6 @@ Designed to help you write simple, readable, and maintainable tests that do not
40
40
  - Works great with [c8](https://github.com/bcoe/c8) for code coverage out of the box (see [getting started](docs/gettingStarted.md)).
41
41
  - Handles compilation errors gracefully.
42
42
 
43
- ## Installation
44
-
45
- ```bash
46
- npm i -D kizu
47
- ```
48
-
49
- **Note:** `tsx` is automatically installed as a peer dependency for TypeScript support. kizu will use it for fast TypeScript compilation.
50
-
51
- ## Module System Support (ESM & CJS)
52
-
53
- kizu works seamlessly with both **CommonJS (CJS)** and **ES Modules (ESM)** projects. Here's how it handles different module systems:
54
-
55
- ### **How It Works**
56
-
57
- kizu uses a **hybrid approach** that gives you the best of both worlds:
58
-
59
- - **Test Runner**: Runs in CommonJS mode for maximum compatibility
60
- - **Your Test Code**: Can use any module system (CJS or ESM)
61
- - **TypeScript Compilation**: Uses `tsx` for fast TypeScript compilation
62
-
63
- ### **ESM Projects**
64
-
65
- If your project uses ESM (`"type": "module"` in package.json):
66
-
67
- ```typescript
68
- // test.spec.ts - Your test files can use ESM syntax
69
- import { test } from 'kizu';
70
- import { myESMFunction } from './myESMModule.js'; // ESM imports work fine
71
-
72
- test('ESM test', (assert) => {
73
- const result = myESMFunction();
74
- assert.equal(result, 'expected');
75
- });
76
- ```
77
-
78
- **What happens:**
79
- 1. kizu uses `tsx` to compile your TypeScript files to JavaScript
80
- 2. Runs the compiled code (which preserves your ESM imports/exports)
81
- 3. Your ESM code works exactly as expected
82
-
83
- ### **CJS Projects**
84
-
85
- If your project uses CommonJS:
86
-
87
- ```typescript
88
- // test.spec.ts - Your test files can use CJS syntax
89
- import { test } from 'kizu';
90
- const { myFunction } = require('./myModule'); // CJS imports work fine
91
-
92
- test('CJS test', (assert) => {
93
- const result = myFunction();
94
- assert.equal(result, 'expected');
95
- });
96
- ```
97
-
98
- ### **Why This Approach?**
99
-
100
- **Benefits:**
101
- - ✅ **Works everywhere** - No module system conflicts
102
- - ✅ **Uses your TypeScript setup** - Respects your tsconfig
103
- - ✅ **No build step needed** - Runs tests immediately
104
- - ✅ **Predictable behavior** - Same experience across projects
105
-
106
- **Technical Details:**
107
- - kizu uses `tsx` for TypeScript compilation (fast and reliable)
108
- - This prevents module system conflicts in the test runner
109
- - Your test code can still use any module system
110
- - The compilation preserves your original module syntax
111
-
112
- ### **Mocking Dependencies**
113
-
114
- **For CJS modules:** Use [cjs-mock](https://github.com/mhweiner/cjs-mock) for easy dependency mocking:
115
-
116
- ```typescript
117
- import { test } from 'kizu';
118
- import { mock } from 'cjs-mock';
119
-
120
- test('mocked test', (assert) => {
121
- const mockedModule = mock('./myModule', {
122
- './dependency': { someFunction: () => 'mocked' }
123
- });
124
-
125
- assert.equal(mockedModule.doSomething(), 'mocked');
126
- });
127
- ```
128
-
129
- **For ESM modules:** ESM mocking is more complex and not fully supported by most tools. Jest has some ESM mocking capabilities, but they're limited and can be unreliable. For the best testing experience, consider using CJS for modules you need to mock.
130
-
131
- If you have any issues running in ESM projects, please [open an issue](https://github.com/mhweiner/kizu/issues).
132
-
133
43
  ## Quick Examples
134
44
 
135
45
  For more examples, see the [examples](examples) and [src](src) folders.
@@ -137,7 +47,8 @@ For more examples, see the [examples](examples) and [src](src) folders.
137
47
  ```bash
138
48
  # Run all tests in the src directory and its subdirectories, and only show failures in the output.
139
49
  npx kizu 'src/**/*.test.ts' --fail-only
140
- # Run a specific test file
50
+
51
+ # Run a specific test file and show all output
141
52
  npx kizu 'src/example.test.ts'
142
53
  ```
143
54
 
@@ -161,64 +72,24 @@ test('user object', (assert) => {
161
72
  name: 'John',
162
73
  age: 30,
163
74
  email: 'john@example.com',
75
+ hobbies: ['reading', 'coding', 'hiking'],
164
76
  preferences: {
165
77
  theme: 'dark',
166
78
  notifications: true
167
79
  }
168
80
  };
169
-
170
81
  const expected = {
171
- name: 'John',
172
- age: 30,
173
- email: 'john@example.com',
82
+ name: /^[A-Za-z]+$/,
83
+ age: /^\d+$/,
84
+ email: /^[^@]+@[^@]+\.[^@]+$/,
85
+ hobbies: ['reading', 'coding', 'hiking'],
174
86
  preferences: {
175
87
  theme: 'dark',
176
88
  notifications: true
177
89
  }
178
90
  };
179
91
 
180
- assert.equal(actual, expected); // Deep equality comparison
181
- });
182
-
183
- // RegExp pattern matching ✨ NEW!
184
- test('email validation', (assert) => {
185
- const email = 'user@example.com';
186
-
187
- // Match email pattern
188
- assert.equal(email, /^[^@]+@[^@]+\.[^@]+$/);
189
-
190
- // Match domain
191
- assert.equal(email, /@example\.com$/);
192
-
193
- // Match username
194
- assert.equal(email, /^user@/);
195
- });
196
-
197
- // Complex data structures
198
- test('complex data', (assert) => {
199
- const actual = {
200
- users: [
201
- { name: 'Alice', email: 'alice@company.com' },
202
- { name: 'Bob', email: 'bob@company.com' }
203
- ],
204
- metadata: {
205
- count: 2,
206
- lastUpdated: '2024-01-15'
207
- }
208
- };
209
-
210
- const expected = {
211
- users: [
212
- { name: 'Alice', email: /@company\.com$/ }, // RegExp in nested objects!
213
- { name: 'Bob', email: /@company\.com$/ }
214
- ],
215
- metadata: {
216
- count: 2,
217
- lastUpdated: /^\d{4}-\d{2}-\d{2}$/ // Date pattern
218
- }
219
- };
220
-
221
- assert.equal(actual, expected);
92
+ assert.equal(actual, expected); // Complex & deep strict object comparison by value, type-safe, and with regular expressions!
222
93
  });
223
94
 
224
95
  // Error handling
@@ -243,9 +114,10 @@ test('fetchData', async (assert) => {
243
114
 
244
115
  ## Table of Contents
245
116
 
246
- - [Quick Start](docs/quickStart.md)
117
+ - [Installation & Setup](docs/setup.md)
118
+ - [ESM Support](docs/esm.md)
247
119
  - [CLI](docs/cli.md)
248
- - [Test API](docs/api.md)
120
+ - [Assertion API](docs/api.md)
249
121
  - [Visual Diff Tool](docs/visualDiff.md)
250
122
  - [Example Tests](examples)
251
123
  - [Best Practices](docs/bestPractices.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kizu",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
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",