@epikodelabs/testify 1.0.16 → 1.0.17
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 +309 -256
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,27 +2,61 @@
|
|
|
2
2
|
|
|
3
3
|
A flexible test runner for Jasmine that supports multiple execution environments with built-in TypeScript compilation, hot module reloading, and code coverage.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> “**testify** doesn’t mock the browser. It invites the browser into the courtroom and asks it to testify under oath.”
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://github.com/epikodelabs/testify/actions/workflows/build.yml">
|
|
9
|
+
<img src="https://github.com/epikodelabs/testify/actions/workflows/build.yml/badge.svg?branch=main" alt="Build Status">
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/@epikodelabs/testify">
|
|
12
|
+
<img src="https://img.shields.io/npm/v/@epikodelabs/testify.svg?style=flat-square" alt="NPM Version">
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/@epikodelabs/testify">
|
|
15
|
+
<img src="https://img.shields.io/npm/dm/@epikodelabs/testify.svg?style=flat-square" alt="NPM Downloads">
|
|
16
|
+
</a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
## Give a Star on GitHub
|
|
20
|
+
|
|
21
|
+
If testify helps you, please give it a star: https://github.com/epikodelabs/testify
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
25
|
-
##
|
|
25
|
+
## ✨ Why testify
|
|
26
|
+
|
|
27
|
+
**testify** is a modern test runner built for Jasmine that bridges the gap between fast unit testing and real browser testing. Whether you need blazing-fast feedback loops in Node.js or full DOM testing in actual browsers (yes, *actual* browsers—not JSDOM pretending to be one), testify adapts to your workflow with hot module reloading, TypeScript-first design, and zero-config coverage reporting. It's like having a Swiss Army knife for testing, except it actually works and won't get confiscated at the airport.
|
|
28
|
+
|
|
29
|
+
### Highlights
|
|
30
|
+
|
|
31
|
+
- 🌐 Real browsers (Chrome, Firefox, Safari) for DOM and browser API testing
|
|
32
|
+
- ⚡ Node.js execution for lightning-fast unit tests
|
|
33
|
+
- 🔥 Hot Module Reload for instant test feedback during development
|
|
34
|
+
- 📦 TypeScript compilation with source maps out of the box
|
|
35
|
+
- 📊 Istanbul code coverage with beautiful HTML reports
|
|
36
|
+
- 🎯 Interactive browser-based test reporter
|
|
37
|
+
- 🔧 VS Code debug integration for single-spec debugging
|
|
38
|
+
|
|
39
|
+
### Why "testify"?
|
|
40
|
+
|
|
41
|
+
Look, we'll be honest. Coming up with a testing library name in 2025 is like trying to find a good username on Twitter in 2010. Everything's taken. We considered:
|
|
42
|
+
|
|
43
|
+
- `test-runner` - Too generic (also taken)
|
|
44
|
+
- `jasmine-tester` - Too obvious (also taken)
|
|
45
|
+
- `vite-jasmine-runner` - Too long (and, you guessed it, taken)
|
|
46
|
+
- `super-mega-awesome-test-framework` - Too humble
|
|
47
|
+
|
|
48
|
+
So we landed on `testify` because:
|
|
49
|
+
1. Your tests should be able to testify about your code in court 🧑⚖️
|
|
50
|
+
2. It sounds vaguely spiritual, which you'll need when debugging flaky tests 🙏
|
|
51
|
+
3. The npm package name was actually available 🎉
|
|
52
|
+
4. It has the word "test" in it (we're nothing if not literal)
|
|
53
|
+
|
|
54
|
+
> **⚖️ The testify Promise**
|
|
55
|
+
> *testify doesn't mock the browser. It invites the browser into the courtroom and asks it to testify under oath.*
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 📦 Installation
|
|
26
60
|
|
|
27
61
|
```bash
|
|
28
62
|
# Install the test runner
|
|
@@ -34,9 +68,9 @@ npx playwright install
|
|
|
34
68
|
|
|
35
69
|
---
|
|
36
70
|
|
|
37
|
-
## Quick
|
|
71
|
+
## ⚡️ Quick start
|
|
38
72
|
|
|
39
|
-
### 1. Initialize
|
|
73
|
+
### 1. Initialize configuration
|
|
40
74
|
|
|
41
75
|
```bash
|
|
42
76
|
npx testify init
|
|
@@ -56,7 +90,7 @@ This creates `testify.json` with sensible defaults:
|
|
|
56
90
|
}
|
|
57
91
|
```
|
|
58
92
|
|
|
59
|
-
### 2. Write Jasmine
|
|
93
|
+
### 2. Write Jasmine tests
|
|
60
94
|
|
|
61
95
|
Create `.spec.ts` files in your test directory:
|
|
62
96
|
|
|
@@ -83,7 +117,7 @@ describe('Calculator', () => {
|
|
|
83
117
|
});
|
|
84
118
|
```
|
|
85
119
|
|
|
86
|
-
### 3. Run
|
|
120
|
+
### 3. Run your tests
|
|
87
121
|
|
|
88
122
|
```bash
|
|
89
123
|
# Development: Interactive browser mode
|
|
@@ -104,11 +138,11 @@ npx testify --watch
|
|
|
104
138
|
|
|
105
139
|
---
|
|
106
140
|
|
|
107
|
-
## Execution
|
|
141
|
+
## 🎯 Execution modes
|
|
108
142
|
|
|
109
|
-
### Browser
|
|
143
|
+
### 🌐 Browser mode (Default)
|
|
110
144
|
|
|
111
|
-
**Best for:** Development and debugging
|
|
145
|
+
**Best for:** Development and debugging (and feeling like a real developer)
|
|
112
146
|
|
|
113
147
|
```bash
|
|
114
148
|
npx testify
|
|
@@ -116,12 +150,13 @@ npx testify
|
|
|
116
150
|
|
|
117
151
|
- Opens `http://localhost:8888` in your default browser
|
|
118
152
|
- Interactive HTML test reporter with Jasmine UI
|
|
119
|
-
- Full browser DevTools for debugging
|
|
153
|
+
- Full browser DevTools for debugging (F12 is your friend)
|
|
120
154
|
- Access to DOM, localStorage, fetch, and all browser APIs
|
|
155
|
+
- Watch your tests fail in glorious 1080p
|
|
121
156
|
|
|
122
|
-
### Headless
|
|
157
|
+
### 🤖 Headless browser mode
|
|
123
158
|
|
|
124
|
-
**Best for:** CI/CD and automated testing
|
|
159
|
+
**Best for:** CI/CD and automated testing (robots don't need screens)
|
|
125
160
|
|
|
126
161
|
```bash
|
|
127
162
|
# Chrome (default)
|
|
@@ -130,27 +165,29 @@ npx testify --headless
|
|
|
130
165
|
# Firefox
|
|
131
166
|
npx testify --headless --browser firefox
|
|
132
167
|
|
|
133
|
-
# Safari/WebKit
|
|
168
|
+
# Safari/WebKit (for the brave)
|
|
134
169
|
npx testify --headless --browser webkit
|
|
135
170
|
```
|
|
136
171
|
|
|
137
|
-
- Runs real browser without UI
|
|
172
|
+
- Runs real browser without UI (like a browser in witness protection)
|
|
138
173
|
- Full browser API support
|
|
139
174
|
- Console output with test results
|
|
140
175
|
- Excellent for cross-browser testing
|
|
176
|
+
- No awkward eye contact with DevTools
|
|
141
177
|
|
|
142
|
-
### Node.js
|
|
178
|
+
### ⚡ Node.js mode
|
|
143
179
|
|
|
144
|
-
**Best for:** Fast unit testing
|
|
180
|
+
**Best for:** Fast unit testing (when you just want to go home early)
|
|
145
181
|
|
|
146
182
|
```bash
|
|
147
183
|
npx testify --headless --browser node
|
|
148
184
|
```
|
|
149
185
|
|
|
150
|
-
- Fastest execution (no browser startup overhead)
|
|
186
|
+
- Fastest execution (no browser startup overhead—just pure speed)
|
|
151
187
|
- Limited to Node.js APIs only
|
|
152
|
-
- Perfect for pure TypeScript logic
|
|
188
|
+
- Perfect for pure TypeScript logic that doesn't need a browser's emotional support
|
|
153
189
|
- No DOM or browser-specific APIs
|
|
190
|
+
- Your tests run so fast you'll think they're not even running (they are, we promise)
|
|
154
191
|
|
|
155
192
|
**Suppress console output:**
|
|
156
193
|
```bash
|
|
@@ -167,25 +204,26 @@ npx testify --headless --browser node --quiet
|
|
|
167
204
|
TS_TEST_RUNNER_SUPPRESS_CONSOLE_LOGS=1 npx testify --headless --browser node
|
|
168
205
|
```
|
|
169
206
|
|
|
170
|
-
### Watch
|
|
207
|
+
### 🔥 Watch mode
|
|
171
208
|
|
|
172
|
-
**Best for:** Rapid development iteration
|
|
209
|
+
**Best for:** Rapid development iteration (and existential dread watching tests fail in real-time)
|
|
173
210
|
|
|
174
211
|
```bash
|
|
175
212
|
npx testify --watch
|
|
176
213
|
```
|
|
177
214
|
|
|
178
|
-
- Hot Module Reload for instant feedback
|
|
179
|
-
- Watches source and test files for changes
|
|
215
|
+
- Hot Module Reload for instant feedback (faster than your morning coffee)
|
|
216
|
+
- Watches source and test files for changes (like a very attentive guard dog)
|
|
180
217
|
- Automatically re-runs affected tests
|
|
181
218
|
- Only works in headed browser mode
|
|
182
219
|
- WebSocket-based synchronization
|
|
220
|
+
- Warning: May cause productivity addiction
|
|
183
221
|
|
|
184
|
-
**Important:** Watch mode cannot be combined with `--headless` or `--coverage`.
|
|
222
|
+
**Important:** Watch mode cannot be combined with `--headless` or `--coverage`. (We tried. The universe said no.)
|
|
185
223
|
|
|
186
224
|
---
|
|
187
225
|
|
|
188
|
-
## Code
|
|
226
|
+
## 📊 Code coverage
|
|
189
227
|
|
|
190
228
|
Enable Istanbul code coverage with the `--coverage` flag:
|
|
191
229
|
|
|
@@ -207,122 +245,9 @@ npx testify --coverage
|
|
|
207
245
|
|
|
208
246
|
---
|
|
209
247
|
|
|
210
|
-
##
|
|
211
|
-
|
|
212
|
-
### Configuration File: `testify.json`
|
|
213
|
-
|
|
214
|
-
```json
|
|
215
|
-
{
|
|
216
|
-
// Source and test directories
|
|
217
|
-
"srcDirs": ["./src/lib"],
|
|
218
|
-
"testDirs": ["./src/tests"],
|
|
219
|
-
"exclude": ["**/node_modules/**", "**/.git/**"],
|
|
220
|
-
|
|
221
|
-
// Build output
|
|
222
|
-
"outDir": "./dist/.vite-jasmine-build",
|
|
223
|
-
"preserveOutputs": false,
|
|
224
|
-
|
|
225
|
-
// Execution settings
|
|
226
|
-
"browser": "chrome",
|
|
227
|
-
"headless": false,
|
|
228
|
-
"port": 8888,
|
|
229
|
-
"coverage": false,
|
|
230
|
-
"watch": false,
|
|
231
|
-
"suppressConsoleLogs": false,
|
|
232
|
-
|
|
233
|
-
// TypeScript configuration
|
|
234
|
-
"tsconfig": "tsconfig.json",
|
|
235
|
-
|
|
236
|
-
// Jasmine configuration
|
|
237
|
-
"jasmineConfig": {
|
|
238
|
-
"env": {
|
|
239
|
-
"random": true,
|
|
240
|
-
"seed": 0,
|
|
241
|
-
"timeout": 120000,
|
|
242
|
-
"stopSpecOnExpectationFailure": false
|
|
243
|
-
}
|
|
244
|
-
},
|
|
245
|
-
|
|
246
|
-
// HTML page customization
|
|
247
|
-
"htmlOptions": {
|
|
248
|
-
"title": "My Project Tests"
|
|
249
|
-
},
|
|
250
|
-
|
|
251
|
-
// Vite build options
|
|
252
|
-
"viteBuildOptions": {
|
|
253
|
-
"target": "es2022",
|
|
254
|
-
"sourcemap": true,
|
|
255
|
-
"minify": false
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
### Configuration Options
|
|
261
|
-
|
|
262
|
-
| Option | Type | Default | Description |
|
|
263
|
-
|--------|------|---------|-------------|
|
|
264
|
-
| `srcDirs` | `string[]` | `["./src"]` | Source code directories |
|
|
265
|
-
| `testDirs` | `string[]` | `["./tests"]` | Test file directories |
|
|
266
|
-
| `exclude` | `string[]` | `["**/node_modules/**"]` | Patterns to exclude |
|
|
267
|
-
| `outDir` | `string` | `"./dist/.vite-jasmine-build"` | Build output directory |
|
|
268
|
-
| `browser` | `string` | `"chrome"` | Browser to use: `chrome`, `firefox`, `webkit`, `node` |
|
|
269
|
-
| `headless` | `boolean` | `false` | Run in headless mode |
|
|
270
|
-
| `port` | `number` | `8888` | Development server port |
|
|
271
|
-
| `coverage` | `boolean` | `false` | Enable code coverage |
|
|
272
|
-
| `watch` | `boolean` | `false` | Enable watch mode with HMR |
|
|
273
|
-
| `suppressConsoleLogs` | `boolean` | `false` | Hide spec-level console output in Node mode |
|
|
274
|
-
| `preserveOutputs` | `boolean` | `false` | Skip regenerating outputs when they exist |
|
|
275
|
-
|
|
276
|
-
---
|
|
277
|
-
|
|
278
|
-
## Command Line Reference
|
|
248
|
+
## 🧪 Environment-specific testing
|
|
279
249
|
|
|
280
|
-
###
|
|
281
|
-
|
|
282
|
-
| Command | Description |
|
|
283
|
-
|---------|-------------|
|
|
284
|
-
| `npx testify` | Run in browser (development mode) |
|
|
285
|
-
| `npx testify init` | Create configuration file |
|
|
286
|
-
| `npx testify --help` | Show help message |
|
|
287
|
-
|
|
288
|
-
### Execution Flags
|
|
289
|
-
|
|
290
|
-
| Flag | Description |
|
|
291
|
-
|------|-------------|
|
|
292
|
-
| `--headless` | Run in headless mode |
|
|
293
|
-
| `--browser <n>` | Choose browser: `chrome`, `firefox`, `webkit`, `node` |
|
|
294
|
-
| `--watch` | Enable watch mode with HMR |
|
|
295
|
-
| `--coverage` | Generate code coverage reports |
|
|
296
|
-
| `--seed <number>` | Set randomization seed |
|
|
297
|
-
| `--silent` / `--quiet` | Suppress console logs (Node mode only) |
|
|
298
|
-
| `--preserve` | Skip regenerating outputs when they exist |
|
|
299
|
-
| `--config <path>` | Use custom config file |
|
|
300
|
-
|
|
301
|
-
### Examples
|
|
302
|
-
|
|
303
|
-
```bash
|
|
304
|
-
# Development workflow
|
|
305
|
-
npx testify --watch
|
|
306
|
-
|
|
307
|
-
# CI/CD pipeline
|
|
308
|
-
npx testify --headless --coverage
|
|
309
|
-
|
|
310
|
-
# Cross-browser testing
|
|
311
|
-
npx testify --headless --browser firefox
|
|
312
|
-
npx testify --headless --browser webkit
|
|
313
|
-
|
|
314
|
-
# Deterministic test order
|
|
315
|
-
npx testify --seed 12345
|
|
316
|
-
|
|
317
|
-
# Fast unit tests with clean console
|
|
318
|
-
npx testify --headless --browser node --silent
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
---
|
|
322
|
-
|
|
323
|
-
## Environment-Specific Testing
|
|
324
|
-
|
|
325
|
-
### Browser-Only Tests
|
|
250
|
+
### Browser-only tests
|
|
326
251
|
|
|
327
252
|
```typescript
|
|
328
253
|
describe('Browser APIs', () => {
|
|
@@ -350,7 +275,7 @@ describe('Browser APIs', () => {
|
|
|
350
275
|
});
|
|
351
276
|
```
|
|
352
277
|
|
|
353
|
-
### Node.js-
|
|
278
|
+
### Node.js-only tests
|
|
354
279
|
|
|
355
280
|
```typescript
|
|
356
281
|
describe('Node.js APIs', () => {
|
|
@@ -373,7 +298,7 @@ describe('Node.js APIs', () => {
|
|
|
373
298
|
});
|
|
374
299
|
```
|
|
375
300
|
|
|
376
|
-
### Cross-
|
|
301
|
+
### Cross-environment tests
|
|
377
302
|
|
|
378
303
|
```typescript
|
|
379
304
|
describe('Universal Code', () => {
|
|
@@ -393,7 +318,7 @@ describe('Universal Code', () => {
|
|
|
393
318
|
|
|
394
319
|
---
|
|
395
320
|
|
|
396
|
-
## Single
|
|
321
|
+
## 🐛 Single spec runner (jasmine)
|
|
397
322
|
|
|
398
323
|
Run a single spec file in Node.js using `jasmine-core`:
|
|
399
324
|
|
|
@@ -407,7 +332,7 @@ node --loader @epikodelabs/testify/esm-loader.mjs \
|
|
|
407
332
|
--spec ./tests/example.spec.ts
|
|
408
333
|
```
|
|
409
334
|
|
|
410
|
-
### VS Code
|
|
335
|
+
### VS Code debug configuration
|
|
411
336
|
|
|
412
337
|
Create or update `.vscode/launch.json`:
|
|
413
338
|
|
|
@@ -438,7 +363,7 @@ Or manually add this configuration:
|
|
|
438
363
|
|
|
439
364
|
**Important:** Do not point at `node_modules/.bin/jasmine` (shell shim). Always use the full path to the actual JS file.
|
|
440
365
|
|
|
441
|
-
### jasmine
|
|
366
|
+
### jasmine options
|
|
442
367
|
|
|
443
368
|
```bash
|
|
444
369
|
npx jasmine --spec <path> # Path to spec file
|
|
@@ -451,9 +376,9 @@ npx jasmine init # Create VS Code debug config
|
|
|
451
376
|
|
|
452
377
|
---
|
|
453
378
|
|
|
454
|
-
## CI/CD
|
|
379
|
+
## 🚀 CI/CD integration
|
|
455
380
|
|
|
456
|
-
### GitHub Actions
|
|
381
|
+
### GitHub Actions example
|
|
457
382
|
|
|
458
383
|
```yaml
|
|
459
384
|
name: Tests
|
|
@@ -490,131 +415,181 @@ jobs:
|
|
|
490
415
|
files: ./coverage/lcov.info
|
|
491
416
|
```
|
|
492
417
|
|
|
493
|
-
### Performance
|
|
418
|
+
### Performance comparison
|
|
494
419
|
|
|
495
420
|
| Environment | Speed | Browser APIs | Use Case |
|
|
496
421
|
|-------------|-------|-------------|----------|
|
|
497
|
-
| Node.js | ⚡ Fastest | ❌ None | Unit tests, pure logic |
|
|
498
|
-
| Headless Chrome | 🐌 Medium | ✅ Full | Integration tests, DOM |
|
|
499
|
-
| Headless Firefox | 🐌 Medium | ✅ Full | Cross-browser testing |
|
|
500
|
-
| Browser (headed) | 🐌 Slowest | ✅ Full + DevTools | Development, debugging |
|
|
422
|
+
| Node.js | ⚡ Fastest (blink and you'll miss it) | ❌ None | Unit tests, pure logic |
|
|
423
|
+
| Headless Chrome | 🐌 Medium (coffee break pace) | ✅ Full | Integration tests, DOM |
|
|
424
|
+
| Headless Firefox | 🐌 Medium (also coffee break pace) | ✅ Full | Cross-browser testing |
|
|
425
|
+
| Browser (headed) | 🐌 Slowest (full meal pace) | ✅ Full + DevTools | Development, debugging |
|
|
501
426
|
|
|
502
427
|
---
|
|
503
428
|
|
|
504
|
-
##
|
|
429
|
+
## ⚖️ testify vs other test runners
|
|
505
430
|
|
|
506
|
-
|
|
431
|
+
| Feature | testify | Jest | Vitest | Karma |
|
|
432
|
+
|---------|---------|------|--------|-------|
|
|
433
|
+
| Real browser testing | ✅ | ❌ | ❌ | ✅ |
|
|
434
|
+
| Node.js execution | ✅ | ✅ | ✅ | ❌ |
|
|
435
|
+
| Hot Module Reload | ✅ | ✅ | ✅ | ❌ |
|
|
436
|
+
| TypeScript support | ✅ | ✅ | ✅ | ⚠️ Plugin |
|
|
437
|
+
| Code coverage | ✅ | ✅ | ✅ | ✅ |
|
|
438
|
+
| Setup complexity | Low | Medium | Low | High |
|
|
439
|
+
| Jasmine framework | ✅ | ❌ | ❌ | ✅ |
|
|
440
|
+
| Active maintenance | ✅ | ✅ | ✅ | ⚠️ Limited |
|
|
441
|
+
| Name sounds like courtroom drama | ✅ | ❌ | ❌ | ⚠️ Kinda |
|
|
507
442
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
│ │ ├── calculator.ts
|
|
513
|
-
│ │ └── utils.ts
|
|
514
|
-
│ └── tests/ # Test files
|
|
515
|
-
│ ├── calculator.spec.ts
|
|
516
|
-
│ └── utils.spec.ts
|
|
517
|
-
├── dist/
|
|
518
|
-
│ └── .vite-jasmine-build/ # Compiled output (auto-generated)
|
|
519
|
-
│ ├── index.html
|
|
520
|
-
│ ├── test-runner.js
|
|
521
|
-
│ └── *.js
|
|
522
|
-
├── coverage/ # Coverage reports (auto-generated)
|
|
523
|
-
│ ├── index.html
|
|
524
|
-
│ └── lcov.info
|
|
525
|
-
├── testify.json # Configuration file
|
|
526
|
-
└── tsconfig.json # TypeScript configuration
|
|
527
|
-
```
|
|
443
|
+
**Why choose testify:**
|
|
444
|
+
- **vs Jest:** Better real browser testing support, actual browser environments (and our name is easier to spell)
|
|
445
|
+
- **vs Vitest:** Established Jasmine ecosystem, simpler for existing Jasmine users (also, we tested our name—it works)
|
|
446
|
+
- **vs Karma:** Modern tooling, TypeScript-first, simpler setup, active development (and way less karmic baggage)
|
|
528
447
|
|
|
529
448
|
---
|
|
530
449
|
|
|
531
|
-
##
|
|
532
|
-
|
|
533
|
-
### Browser Not Found
|
|
450
|
+
## 🔧 Configuration reference
|
|
534
451
|
|
|
535
|
-
|
|
536
|
-
# Install all browsers
|
|
537
|
-
npx playwright install
|
|
538
|
-
|
|
539
|
-
# Or install specific browser
|
|
540
|
-
npx playwright install chrome
|
|
541
|
-
npx playwright install firefox
|
|
542
|
-
npx playwright install webkit
|
|
543
|
-
```
|
|
544
|
-
|
|
545
|
-
### Port Already in Use
|
|
546
|
-
|
|
547
|
-
Change the port in `testify.json`:
|
|
452
|
+
### Configuration file: `testify.json`
|
|
548
453
|
|
|
549
454
|
```json
|
|
550
455
|
{
|
|
551
|
-
|
|
456
|
+
// Source and test directories
|
|
457
|
+
"srcDirs": ["./src/lib"],
|
|
458
|
+
"testDirs": ["./src/tests"],
|
|
459
|
+
"exclude": ["**/node_modules/**", "**/.git/**"],
|
|
460
|
+
|
|
461
|
+
// Build output
|
|
462
|
+
"outDir": "./dist/.vite-jasmine-build",
|
|
463
|
+
"preserveOutputs": false,
|
|
464
|
+
|
|
465
|
+
// Execution settings
|
|
466
|
+
"browser": "chrome",
|
|
467
|
+
"headless": false,
|
|
468
|
+
"port": 8888,
|
|
469
|
+
"coverage": false,
|
|
470
|
+
"watch": false,
|
|
471
|
+
"suppressConsoleLogs": false,
|
|
472
|
+
|
|
473
|
+
// TypeScript configuration
|
|
474
|
+
"tsconfig": "tsconfig.json",
|
|
475
|
+
|
|
476
|
+
// Jasmine configuration
|
|
477
|
+
"jasmineConfig": {
|
|
478
|
+
"env": {
|
|
479
|
+
"random": true,
|
|
480
|
+
"seed": 0,
|
|
481
|
+
"timeout": 120000,
|
|
482
|
+
"stopSpecOnExpectationFailure": false
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
|
|
486
|
+
// HTML page customization
|
|
487
|
+
"htmlOptions": {
|
|
488
|
+
"title": "My Project Tests"
|
|
489
|
+
},
|
|
490
|
+
|
|
491
|
+
// Vite build options
|
|
492
|
+
"viteBuildOptions": {
|
|
493
|
+
"target": "es2022",
|
|
494
|
+
"sourcemap": true,
|
|
495
|
+
"minify": false
|
|
496
|
+
}
|
|
552
497
|
}
|
|
553
498
|
```
|
|
554
499
|
|
|
555
|
-
|
|
500
|
+
### Configuration options
|
|
556
501
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
502
|
+
| Option | Type | Default | Description |
|
|
503
|
+
|--------|------|---------|-------------|
|
|
504
|
+
| `srcDirs` | `string[]` | `["./src"]` | Source code directories |
|
|
505
|
+
| `testDirs` | `string[]` | `["./tests"]` | Test file directories |
|
|
506
|
+
| `exclude` | `string[]` | `["**/node_modules/**"]` | Patterns to exclude |
|
|
507
|
+
| `outDir` | `string` | `"./dist/.vite-jasmine-build"` | Build output directory |
|
|
508
|
+
| `browser` | `string` | `"chrome"` | Browser to use: `chrome`, `firefox`, `webkit`, `node` |
|
|
509
|
+
| `headless` | `boolean` | `false` | Run in headless mode |
|
|
510
|
+
| `port` | `number` | `8888` | Development server port |
|
|
511
|
+
| `coverage` | `boolean` | `false` | Enable code coverage |
|
|
512
|
+
| `watch` | `boolean` | `false` | Enable watch mode with HMR |
|
|
513
|
+
| `suppressConsoleLogs` | `boolean` | `false` | Hide spec-level console output in Node mode |
|
|
514
|
+
| `preserveOutputs` | `boolean` | `false` | Skip regenerating outputs when they exist |
|
|
561
515
|
|
|
562
|
-
|
|
516
|
+
---
|
|
563
517
|
|
|
564
|
-
|
|
565
|
-
- Test files are in the `testDirs` location
|
|
566
|
-
- Files have `.spec.ts` or `.spec.js` extension
|
|
567
|
-
- Tests use proper Jasmine syntax (`describe`, `it`, `expect`)
|
|
568
|
-
- Directories are not in the `exclude` list
|
|
518
|
+
## 📖 Command line reference
|
|
569
519
|
|
|
570
|
-
###
|
|
520
|
+
### Basic commands
|
|
571
521
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
522
|
+
| Command | Description |
|
|
523
|
+
|---------|-------------|
|
|
524
|
+
| `npx testify` | Run in browser (development mode) |
|
|
525
|
+
| `npx testify init` | Create configuration file |
|
|
526
|
+
| `npx testify --help` | Show help message |
|
|
576
527
|
|
|
577
|
-
###
|
|
528
|
+
### Execution flags
|
|
529
|
+
|
|
530
|
+
| Flag | Description |
|
|
531
|
+
|------|-------------|
|
|
532
|
+
| `--headless` | Run in headless mode |
|
|
533
|
+
| `--browser <n>` | Choose browser: `chrome`, `firefox`, `webkit`, `node` |
|
|
534
|
+
| `--watch` | Enable watch mode with HMR |
|
|
535
|
+
| `--coverage` | Generate code coverage reports |
|
|
536
|
+
| `--seed <number>` | Set randomization seed |
|
|
537
|
+
| `--silent` / `--quiet` | Suppress console logs (Node mode only) |
|
|
538
|
+
| `--preserve` | Skip regenerating outputs when they exist |
|
|
539
|
+
| `--config <path>` | Use custom config file |
|
|
578
540
|
|
|
579
|
-
|
|
580
|
-
- Watch mode only works in headed browser mode
|
|
581
|
-
- Cannot use with `--headless` flag
|
|
582
|
-
- Cannot use with `--coverage` flag
|
|
583
|
-
- Cannot use with `--browser node`
|
|
541
|
+
### Examples
|
|
584
542
|
|
|
585
|
-
|
|
543
|
+
```bash
|
|
544
|
+
# Development workflow
|
|
545
|
+
npx testify --watch
|
|
586
546
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
-
|
|
591
|
-
|
|
547
|
+
# CI/CD pipeline
|
|
548
|
+
npx testify --headless --coverage
|
|
549
|
+
|
|
550
|
+
# Cross-browser testing
|
|
551
|
+
npx testify --headless --browser firefox
|
|
552
|
+
npx testify --headless --browser webkit
|
|
553
|
+
|
|
554
|
+
# Deterministic test order
|
|
555
|
+
npx testify --seed 12345
|
|
556
|
+
|
|
557
|
+
# Fast unit tests with clean console
|
|
558
|
+
npx testify --headless --browser node --silent
|
|
559
|
+
```
|
|
592
560
|
|
|
593
561
|
---
|
|
594
562
|
|
|
595
|
-
##
|
|
563
|
+
## 📁 Project structure
|
|
596
564
|
|
|
597
|
-
|
|
598
|
-
|---------|---------------|------|--------|-------|
|
|
599
|
-
| Real browser testing | ✅ | ❌ | ❌ | ✅ |
|
|
600
|
-
| Node.js execution | ✅ | ✅ | ✅ | ❌ |
|
|
601
|
-
| Hot Module Reload | ✅ | ✅ | ✅ | ❌ |
|
|
602
|
-
| TypeScript support | ✅ | ✅ | ✅ | ⚠️ Plugin |
|
|
603
|
-
| Code coverage | ✅ | ✅ | ✅ | ✅ |
|
|
604
|
-
| Setup complexity | Low | Medium | Low | High |
|
|
605
|
-
| Jasmine framework | ✅ | ❌ | ❌ | ✅ |
|
|
606
|
-
| Active maintenance | ✅ | ✅ | ✅ | ⚠️ Limited |
|
|
565
|
+
The test runner expects this structure (all paths are configurable):
|
|
607
566
|
|
|
608
|
-
|
|
609
|
-
-
|
|
610
|
-
|
|
611
|
-
|
|
567
|
+
```
|
|
568
|
+
your-project/
|
|
569
|
+
├── src/
|
|
570
|
+
│ ├── lib/ # Source code
|
|
571
|
+
│ │ ├── calculator.ts
|
|
572
|
+
│ │ └── utils.ts
|
|
573
|
+
│ └── tests/ # Test files
|
|
574
|
+
│ ├── calculator.spec.ts
|
|
575
|
+
│ └── utils.spec.ts
|
|
576
|
+
├── dist/
|
|
577
|
+
│ └── .vite-jasmine-build/ # Compiled output (auto-generated)
|
|
578
|
+
│ ├── index.html
|
|
579
|
+
│ ├── test-runner.js
|
|
580
|
+
│ └── *.js
|
|
581
|
+
├── coverage/ # Coverage reports (auto-generated)
|
|
582
|
+
│ ├── index.html
|
|
583
|
+
│ └── lcov.info
|
|
584
|
+
├── testify.json # Configuration file
|
|
585
|
+
└── tsconfig.json # TypeScript configuration
|
|
586
|
+
```
|
|
612
587
|
|
|
613
588
|
---
|
|
614
589
|
|
|
615
|
-
## Advanced
|
|
590
|
+
## 🔧 Advanced configuration
|
|
616
591
|
|
|
617
|
-
### Custom Vite
|
|
592
|
+
### Custom Vite configuration
|
|
618
593
|
|
|
619
594
|
You can extend the Vite configuration in `testify.json`:
|
|
620
595
|
|
|
@@ -631,7 +606,7 @@ You can extend the Vite configuration in `testify.json`:
|
|
|
631
606
|
}
|
|
632
607
|
```
|
|
633
608
|
|
|
634
|
-
### TypeScript
|
|
609
|
+
### TypeScript path mapping
|
|
635
610
|
|
|
636
611
|
Path aliases from `tsconfig.json` are automatically resolved:
|
|
637
612
|
|
|
@@ -648,7 +623,7 @@ Path aliases from `tsconfig.json` are automatically resolved:
|
|
|
648
623
|
}
|
|
649
624
|
```
|
|
650
625
|
|
|
651
|
-
### Multiple
|
|
626
|
+
### Multiple source directories
|
|
652
627
|
|
|
653
628
|
```json
|
|
654
629
|
{
|
|
@@ -657,7 +632,7 @@ Path aliases from `tsconfig.json` are automatically resolved:
|
|
|
657
632
|
}
|
|
658
633
|
```
|
|
659
634
|
|
|
660
|
-
### Exclude
|
|
635
|
+
### Exclude patterns
|
|
661
636
|
|
|
662
637
|
```json
|
|
663
638
|
{
|
|
@@ -673,14 +648,92 @@ Path aliases from `tsconfig.json` are automatically resolved:
|
|
|
673
648
|
|
|
674
649
|
---
|
|
675
650
|
|
|
676
|
-
##
|
|
651
|
+
## ❓ Troubleshooting
|
|
652
|
+
|
|
653
|
+
### Browser not found
|
|
654
|
+
|
|
655
|
+
Did you forget to invite the browsers to the party?
|
|
656
|
+
|
|
657
|
+
```bash
|
|
658
|
+
# Install all browsers (the whole squad)
|
|
659
|
+
npx playwright install
|
|
660
|
+
|
|
661
|
+
# Or install specific browser (selective guest list)
|
|
662
|
+
npx playwright install chrome
|
|
663
|
+
npx playwright install firefox
|
|
664
|
+
npx playwright install webkit
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
### Port already in use
|
|
668
|
+
|
|
669
|
+
Someone's camping on port 8888? Rude. Change the port in `testify.json`:
|
|
670
|
+
|
|
671
|
+
```json
|
|
672
|
+
{
|
|
673
|
+
"port": 3000
|
|
674
|
+
}
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
Or use a different port via command line:
|
|
678
|
+
|
|
679
|
+
```bash
|
|
680
|
+
# Note: Currently requires config file change
|
|
681
|
+
# CLI port override coming in future version
|
|
682
|
+
# (We're working on it, okay? Rome wasn't built in a day)
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
### No tests found
|
|
686
|
+
|
|
687
|
+
testify is looking for tests like a detective at a crime scene. Make sure:
|
|
688
|
+
- Test files are in the `testDirs` location (it's not a treasure hunt)
|
|
689
|
+
- Files have `.spec.ts` or `.spec.js` extension (naming conventions matter, people!)
|
|
690
|
+
- Tests use proper Jasmine syntax (`describe`, `it`, `expect`) (no, `console.log` is not a test)
|
|
691
|
+
- Directories are not in the `exclude` list (check if you accidentally ghosted your tests)
|
|
692
|
+
|
|
693
|
+
### TypeScript compilation errors
|
|
694
|
+
|
|
695
|
+
TypeScript is being picky again? Let's troubleshoot:
|
|
696
|
+
|
|
697
|
+
1. Check your `tsconfig.json` matches your project structure (did you move files around and forget to tell TypeScript?)
|
|
698
|
+
2. Ensure `tsconfig` path in `testify.json` is correct (typos happen to the best of us)
|
|
699
|
+
3. Verify path aliases are properly configured (@ symbols need love too)
|
|
700
|
+
4. Check that all dependencies are installed (did you `npm install`? Did you *really*?)
|
|
701
|
+
|
|
702
|
+
### Watch mode not working
|
|
703
|
+
|
|
704
|
+
Watch mode is like that one friend who only shows up under specific conditions:
|
|
705
|
+
- Watch mode only works in headed browser mode (it likes to see what's happening)
|
|
706
|
+
- Cannot use with `--headless` flag (it's shy without a UI)
|
|
707
|
+
- Cannot use with `--coverage` flag (it can't multitask)
|
|
708
|
+
- Cannot use with `--browser node` (needs a real browser, not a pretend one)
|
|
709
|
+
|
|
710
|
+
### Coverage reports missing
|
|
711
|
+
|
|
712
|
+
Coverage reports playing hide and seek? Make sure:
|
|
713
|
+
- `--coverage` flag is used (it's not going to turn on itself)
|
|
714
|
+
- Tests complete successfully (failed tests don't generate coverage, obviously)
|
|
715
|
+
- Output directory (`coverage/`) has write permissions (is it read-only? That's a paddlin')
|
|
716
|
+
- Not using `--watch` mode (coverage and watch mode are like oil and water—they don't mix)
|
|
717
|
+
|
|
718
|
+
---
|
|
719
|
+
|
|
720
|
+
## 📜 License
|
|
677
721
|
|
|
678
722
|
MIT © 2025
|
|
679
723
|
|
|
680
724
|
---
|
|
681
725
|
|
|
682
|
-
## Support
|
|
726
|
+
## 🤝 Support
|
|
683
727
|
|
|
684
728
|
- **Issues:** [GitHub Issues](https://github.com/epikodelabs/testify/issues)
|
|
685
729
|
- **Documentation:** [GitHub Wiki](https://github.com/epikodelabs/testify/wiki)
|
|
686
|
-
- **Changelog:** [CHANGELOG.md](./CHANGELOG.md)
|
|
730
|
+
- **Changelog:** [CHANGELOG.md](./CHANGELOG.md)
|
|
731
|
+
|
|
732
|
+
---
|
|
733
|
+
|
|
734
|
+
<p align="center">
|
|
735
|
+
<strong>Get started</strong><br>
|
|
736
|
+
<a href="https://www.npmjs.com/package/@epikodelabs/testify">Install from NPM</a> •
|
|
737
|
+
<a href="https://github.com/epikodelabs/testify">View on GitHub</a> •
|
|
738
|
+
<a href="https://forms.gle/YOUR_FEEDBACK_FORM_ID">Give Feedback</a>
|
|
739
|
+
</p>
|