-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtesting.mdc
More file actions
39 lines (28 loc) · 1.68 KB
/
testing.mdc
File metadata and controls
39 lines (28 loc) · 1.68 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
39
---
description: "Mocha, Jest, and sanity-check tests for this SDK"
globs:
- "test/unit/**/*.js"
- "test/sanity-check/**/*.js"
- "test/typescript/**/*.ts"
- "test/**/index.js"
alwaysApply: false
---
# Testing — `@contentstack/management`
## Frameworks
| Suite | Runner | Assertion / mocks | Notes |
|-------|--------|-------------------|--------|
| **Unit** | **Mocha** + `@babel/register` | **Chai**, **Sinon**, **Nock**, **axios-mock-adapter** | Entry: `test/unit/index.js`; **30s** timeout in npm script |
| **Sanity / API** | Mocha | Chai; **live HTTP** | Entry: `test/sanity-check/sanity.js`; imports **`dist/node/contentstack-management.js`** — run **`npm run build`** first |
| **TypeScript** | **Jest** + **ts-jest** | Jest mocks | `jest.config.js`; `npm run test:typescript` |
## Naming & layout
- **Unit**: `test/unit/*-test.js` (required from `test/unit/index.js`).
- **Sanity**: `test/sanity-check/api/*-test.js` (orchestrated via `sanity.js`); shared setup in `test/sanity-check/utility/testSetup.js` and helpers.
- **TS**: `test/typescript/**/*.test.ts` per Jest config.
## Credentials & env (sanity only)
- Sanity tests need env vars documented in **`test/sanity-check/utility/testSetup.js`** (`EMAIL`, `PASSWORD`, `HOST`, `ORGANIZATION`, optional OAuth/Personalize). **Do not** commit secrets or hardcode tokens in tests.
- Unit tests must **not** rely on real API keys; mock HTTP.
## Coverage
- **nyc** is used with `npm run test:unit` / `test:sanity-test`; exclusions are configured under `package.json` → `nyc`.
## Hygiene
- No committed **`only`** / **`skip`** for tests that should run in CI.
- Prefer existing **`test/unit/mock/`** and sanity **`mock/`** patterns for fixtures.