| name | testing |
|---|---|
| description | Runs and extends Jest tests for the contentstack-cli-content-type plugin. Use when adding or changing tests under tests/, mocking HTTP or ContentstackClient, configuring Jest, or running npm test and posttest ESLint. |
- Adding or changing files under
tests/or jest.config.js. - Mocking
ContentstackClient, axios, or Management SDK chains. - Verifying coverage after changes in
src/core/orsrc/utils/.
- Framework: Jest with ts-jest for TypeScript.
- Config: jest.config.js at repo root —
testMatchincludes**/tests/**/*.+(ts|tsx)and common*.test.ts/*.spec.tspatterns. - Test location: tests/ (e.g. tests/commands/content-type/audit.test.ts).
| Script | Behavior |
|---|---|
npm test |
Runs Jest |
npm run test:coverage |
Jest with coverage (see jest.config.js) |
npm run posttest |
After tests (when invoked via npm lifecycle), ESLint runs per package.json: eslint . --ext .ts --config .eslintrc |
When validating changes, run npm test; ensure ESLint still passes (posttest or eslint directly). Use npm run test:coverage when changing src/core/ or src/utils/ behavior.
- Pure functions and core builders in
src/core/content-type/with inputs/outputs mocked at the boundary. - ContentstackClient: mock
geton the axios instance or mock the whole module—no live CMA or real stack keys in unit tests. - Commands: prefer testing core and utils first; command tests may require heavy mocking of
@contentstack/cli-utilities(auth, cliux, management SDK).
- references/conventions.md — naming, what to test first, no
.only/.skip, coverage goal. - references/jest-mocking.md — mocking boundaries and minimal patterns.
- dev-workflow/SKILL.md — ESLint and CI expectations.
- AGENTS.md — coverage targets and scripts.