| 1 | --- |
| 2 | name: Unit Testing Rules |
| 3 | description: Guidelines for unit testing in this project |
| 4 | alwaysApply: false |
| 5 | --- |
| 6 | |
| 7 | For unit testing in this project: |
| 8 | |
| 9 | ## 1. Testing frameworks |
| 10 | |
| 11 | The project uses Vitest and Jest for testing. Prefer Vitest. |
| 12 | |
| 13 | ## 2. Test execution location |
| 14 | |
| 15 | Run tests from within the specific package directory (e.g., `cd core && ..`). |
| 16 | |
| 17 | ## 3. Vitest tests |
| 18 | |
| 19 | - Test files follow the pattern `*.vitest.ts` |
| 20 | - Run tests using `vitest` from within the specific package/module directory: |
| 21 | ```bash |
| 22 | cd [directory] && vitest -- [test file path] |
| 23 | ``` |
| 24 | |
| 25 | ## 4. Jest tests |
| 26 | |
| 27 | - Test files follow the pattern `*.test.ts` |
| 28 | - Run tests using `npm test` from within the specific package/module directory: |
| 29 | ```bash |
| 30 | cd [directory] && npm test -- [test file path] |
| 31 | ``` |
| 32 | - The test script uses experimental VM modules via NODE_OPTIONS flag |
| 33 | |
| 34 | ## 5. Test structure |
| 35 | |
| 36 | - Write tests as top-level `test()` functions - DO NOT use `describe()` blocks |
| 37 | - Include the function name being tested in the test description for clarity |