You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project now uses [Vitest](https://vitest.dev/) for unit testing, providing a fast and modern testing experience with excellent TypeScript support.
4
+
5
+
## Available Test Scripts
6
+
7
+
-`npm run test:unit` - Run all unit tests once
8
+
-`npm run test:unit:watch` - Run tests in watch mode (reruns when files change)
9
+
-`npm run test:unit:ui` - Open the Vitest UI for interactive testing
10
+
-`npm test` - Run the full test suite (lint, format check, build, package, grammar tests, and unit tests)
11
+
12
+
## Test Structure
13
+
14
+
### Unit Tests
15
+
- Located in `tests/` directory
16
+
- Use `.test.ts` or `.spec.ts` suffix
17
+
- Written using Vitest's `describe`, `it`, and `expect` APIs
18
+
19
+
### Current Tests
20
+
-`tests/errorParser.test.ts` - Tests for WIT error parsing functionality
21
+
22
+
## Writing Tests
23
+
24
+
```typescript
25
+
import { describe, it, expect } from'vitest';
26
+
import { yourFunction } from'../src/yourModule';
27
+
28
+
describe('Your Module', () => {
29
+
it('should do something', () => {
30
+
const result =yourFunction('input');
31
+
expect(result).toBe('expected output');
32
+
});
33
+
});
34
+
```
35
+
36
+
## Error Parser Tests
37
+
38
+
The `errorParser.test.ts` file contains comprehensive tests for the WIT error parsing regex, including:
39
+
40
+
- Extraction from real WIT error stacks
41
+
- Handling invalid/malformed stacks
42
+
- Edge cases with large line/column numbers
43
+
- Different file path formats
44
+
- Stacks with and without "Caused by" sections
45
+
46
+
## Configuration
47
+
48
+
The Vitest configuration is in `vitest.config.ts` and includes:
49
+
- TypeScript support out of the box
50
+
- Node.js environment
51
+
- Path aliases for cleaner imports
52
+
- Automatic file discovery for tests
53
+
54
+
## VS Code Integration
55
+
56
+
Vitest works great with VS Code. You can:
57
+
1. Install the [Vitest extension](https://marketplace.visualstudio.com/items?itemName=ZixuanChen.vitest-explorer)
0 commit comments