mcpbeat

Write Tests

datadog/write-tests

Write tests for datadog-ci commands and helpers using established repository patterns.

434 tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
161
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/DataDog/datadog-ci --skill write-tests

The instruction itself

5 sections, as written by the author

Write Tests

Write tests for datadog-ci commands and helpers following the repo's established patterns. Before writing tests, read existing tests in the same package to match local patterns.

Conventions

  • Place tests in __tests__/*.test.ts next to the source, fixtures in __tests__/fixtures/

Key test utilities

From packages/base/src/helpers/__tests__/testing-tools.ts:

  • createMockContext(opts?) -- creates a mock context with stdout and stderr writable streams. Use context.stdout.toString() / context.stderr.toString() to check output.
  • makeRunCLI(commandClass, baseArgs, opts?) -- returns an async function (extraArgs, extraEnv?) => {context, code} that registers and runs a command through the full CLI pipeline.
  • createCommand(commandClass, context?) -- instantiates a command with mock context and resolved option defaults. Good for unit-testing command methods directly.
  • MOCK_DATADOG_API_KEY, MOCK_BASE_URL -- standard mock values.
  • getRequestError(status, {errors?, message?}) -- creates a mock RequestError.

Patterns

  • Use jest.spyOn() for mocking, restore in afterEach or use jest.restoreAllMocks()
  • Use jest.mock() for module-level mocks when needed
  • Table-driven tests with describe.each / test.each where appropriate
  • Check both stdout output and exit code
  • For commands that make HTTP requests, mock the request layer (e.g., fetch)

Running tests

yarn test                    # all tests
yarn test <path>             # specific package or file
yarn test --testPathPattern  # regex match

How to use it

Copy the folder

Take datadog/write-tests from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.