-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtesting.mdc
More file actions
38 lines (25 loc) · 1.3 KB
/
testing.mdc
File metadata and controls
38 lines (25 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---
description: Jest tests, mocks, reports, and environments for @contentstack/utils
globs:
- __test__/**/*.ts
alwaysApply: false
---
# Testing — `@contentstack/utils`
## Framework
- **Jest 29** with **`ts-jest`** preset (`jest.config.ts`).
- **Environment:** **`jsdom`** (suitable for HTML string assertions and DOM-related behavior).
## Discovery and naming
- **Pattern:** `**/__test__/**/?(*.)+(spec|test).[jt]s?(x)` — this repo uses `*.test.ts` under **`__test__/`**.
- **Mocks / fixtures:** `__test__/mock/*.ts` — follow existing mock naming (`*-mock.ts`).
## Coverage and reports
- **Coverage** is collected from `src/**` excluding `src/index.ts` (`collectCoverageFrom`).
- Outputs: **`reports/coverage/`**, **`reports/html/`** (jest-html-reporters), **`reports/junit/`** (jest-junit), **`reports/report.json`** (from `npm test` script).
## Running tests
| Command | Behavior |
|---------|----------|
| `npm test` | Runs **`pretest` → build** then Jest (CI-aligned). |
| `npm run test:debug` | Watch mode, `--runInBand`. |
## Integration / live tests
- **None** in this repo. No `.env` or stack credentials required for **`npm test`**.
## Build dependency
- **`npm test` always builds first** (`pretest`). Ensure **`src/assets/regions.json`** exists or can be downloaded so `endpoints` tests pass.