agentleFS
DataDogDataDog/browser-sdk/.claude/skills/writing-tests/SKILL.md

writing-tests

Skill402 starsChanged 10 months agoApache-2.0View on GitHub

Use when you write or change unit tests or end-to-end tests in browser-sdk.

52 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use reviewing-code, commits and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • ZayZay1nonlySkill

    reviewing-code

    Provides structured code review with prioritized feedback. Use when reviewing PRs, analyzing code quality, checking for bugs, or auditing changes. Triggers on "review this", "check this code", PR reviews, or code quality questions.

    Also in 5 projects that use this

  • JetBrainsSkill

    commits

    Read before each commit, amend or reword: the subject SafePush accepts and the body.

    Also in 3 projects that use this

  • BlockSkill

    debugging

    Debugging guidelines and best practices

    Also in 5 projects that use this

  • sahinSkill

    execute

    Also in 3 projects that use this

  • MicrosoftSkill

    council

    Convene the persona panel — six orthogonal review lenses — on a target. Cold independent fan-out, debate-to-consensus, synthesized verdict with recorded dissent and a roster manifest.

    Also in 4 projects that use this

  • stericishereSkill

    graphify

    any input (code, docs, papers, images) → knowledge graph → clustered communities → HTML + JSON + audit report

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 3 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 52 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use should <expected behavior> when <condition>, e.g.

    line 14
  2. Very specific:

    Test framework: Jasmine API on Vitest Browser Mode (via a shim in test/unit-vitest/).

    line 18
  3. Very specific:

    Use registerCleanupTask() for cleanup, NOT afterEach()

    line 21
  4. Very specific:

    Prefer collectAsyncCalls(spy, n) over waitFor(() => spy.calls.count() > 0) for waiting on spy calls

    line 22
  5. Very specific:

    Don't destructure methods from spy.calls (e.g., argsFor, mostRecent) - use calls.argsFor() to avoid @typescript-eslint/unbound-method errors

    line 23
  6. Distinctive:

    Use E2E tests selectively for critical user journeys or failures that lower-level tests cannot catch.

    line 28
  7. Distinctive:

    Before adding an E2E test, check whether an existing one covers the same workflow.

    line 29

“Common” is measured: kept by at least 6 in 10 of the 52 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Writing tests in browser-sdk

What to test

  • Focus testing on critical paths and complex logic instead of every edge case.

Naming convention

  • Use should <expected behavior> when <condition>, e.g. it('should return link when replay is forced', …). Omit the condition when unnecessary.

Unit Tests

  • Test framework: Jasmine API on Vitest Browser Mode (via a shim in test/unit-vitest/). Spec files co-located with implementation: feature.ts → feature.spec.ts
  • Focus tests with fit() / fdescribe(), skip with xit() / xdescribe()
  • Specs are being migrated from the Jasmine API to the Vitest API. Write new specs with the Vitest API (import { describe, expect, it, vi } from 'vitest'), unless they depend on a test helper that still returns Jasmine spies. Convert existing specs with node scripts/test/jasmine-to-vitest.ts <files or directories>, fix what it reports, then add the paths to VITEST_API_SPEC_FILES in eslint.config.ts
  • Use registerCleanupTask() for cleanup, NOT afterEach()
  • Prefer collectAsyncCalls(spy, n) over waitFor(() => spy.calls.count() > 0) for waiting on spy calls
  • Don't destructure methods from spy.calls (e.g., argsFor, mostRecent) - use calls.argsFor() to avoid @typescript-eslint/unbound-method errors
  • Mock values/functions: wrap with mockable() in source, use replaceMockable() or replaceMockableWithSpy() in tests (auto-cleanup)

e2e Tests

  • Use E2E tests selectively for critical user journeys or failures that lower-level tests cannot catch.
  • Before adding an E2E test, check whether an existing one covers the same workflow. Extend it when the new assertion fits its purpose.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.