Source profileQuality 68/100

github/awesome-copilot/skills/javascript-typescript-jest/SKILL.md

javascript-typescript-jest

Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies, test structure, and common patterns.

Source repository stars
37,126
Declared platforms
0
Static risk flags
0
Last source update
2026-07-28
Source checked
2026-07-28

Decision brief

What it does—and where it fits

Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies, test structure, and common patterns.

Best for

    Not for

    • Tasks that require unconfirmed production actions or broad system permissions.
    • Environments where the pinned source and install steps cannot be inspected.

    Compatibility matrix

    Platform support, with evidence labels

    PlatformStatusEvidenceWhat to check
    CodexNot declaredNo explicit evidencePortability before use
    Claude CodeNot declaredNo explicit evidencePortability before use
    CursorNot declaredNo explicit evidencePortability before use
    Gemini CLINot declaredNo explicit evidencePortability before use
    Open the compatibility checker

    Installation

    Inspect first. Install second.

    The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

    Source-detected install commandSource
    npx skills add https://github.com/github/awesome-copilot --skill "skills/javascript-typescript-jest"
    Safe inspection promptEditorial

    Inspect the Agent Skill "javascript-typescript-jest" from https://github.com/github/awesome-copilot/blob/9933dcad5be5caeb288cebcd370eeeb2fc2f1685/skills/javascript-typescript-jest/SKILL.md at commit 9933dcad5be5caeb288cebcd370eeeb2fc2f1685. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

    Workflow

    What the source asks the agent to do

    1. 01

      Test Structure

      Name test files with .test.ts or .test.js suffix

      Name test files with .test.ts or .test.js suffixPlace test files next to the code they test or in a dedicated tests directoryUse descriptive test names that explain the expected behavior
    2. 02

      Effective Mocking

      Mock external dependencies (APIs, databases, etc.) to isolate your tests

      Mock external dependencies (APIs, databases, etc.) to isolate your testsUse jest.mock() for module-level mocksUse jest.spyOn() for specific function mocks
    3. 03

      Testing Async Code

      Always return promises or use async/await syntax in tests

      Always return promises or use async/await syntax in testsUse resolves/rejects matchers for promisesSet appropriate timeouts for slow tests with jest.setTimeout()
    4. 04

      Snapshot Testing

      Use snapshot tests for UI components or complex objects that change infrequently

      Use snapshot tests for UI components or complex objects that change infrequentlyKeep snapshots small and focusedReview snapshot changes carefully before committing

    Permission review

    Static risk signals and limitations

    No configured static risk pattern was detected

    This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.

    Evidence record

    Why each signal appears

    EvidenceSourceComputedTestedEditorial
    SignalValueEvidence typeMeaning
    Quality score68/100ComputedDocumentation, specificity, maintenance, and trust rules
    Repository stars37,126SourceRepository attention, not individual Skill quality
    Compatibility0 platformsSourceDeclared in the catalog source record
    Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

    Pinned source

    Provenance and original SKILL.md

    Repository
    github/awesome-copilot
    Skill path
    skills/javascript-typescript-jest/SKILL.md
    Commit
    9933dcad5be5caeb288cebcd370eeeb2fc2f1685
    License
    MIT
    Collected
    2026-07-28
    Default branch
    main
    View the original SKILL.md

    Test Structure

    • Name test files with .test.ts or .test.js suffix
    • Place test files next to the code they test or in a dedicated __tests__ directory
    • Use descriptive test names that explain the expected behavior
    • Use nested describe blocks to organize related tests
    • Follow the pattern: describe('Component/Function/Class', () => { it('should do something', () => {}) })

    Effective Mocking

    • Mock external dependencies (APIs, databases, etc.) to isolate your tests
    • Use jest.mock() for module-level mocks
    • Use jest.spyOn() for specific function mocks
    • Use mockImplementation() or mockReturnValue() to define mock behavior
    • Reset mocks between tests with jest.resetAllMocks() in afterEach

    Testing Async Code

    • Always return promises or use async/await syntax in tests
    • Use resolves/rejects matchers for promises
    • Set appropriate timeouts for slow tests with jest.setTimeout()

    Snapshot Testing

    • Use snapshot tests for UI components or complex objects that change infrequently
    • Keep snapshots small and focused
    • Review snapshot changes carefully before committing

    Testing React Components

    • Use React Testing Library over Enzyme for testing components
    • Test user behavior and component accessibility
    • Query elements by accessibility roles, labels, or text content
    • Use userEvent over fireEvent for more realistic user interactions

    Common Jest Matchers

    • Basic: expect(value).toBe(expected), expect(value).toEqual(expected)
    • Truthiness: expect(value).toBeTruthy(), expect(value).toBeFalsy()
    • Numbers: expect(value).toBeGreaterThan(3), expect(value).toBeLessThanOrEqual(3)
    • Strings: expect(value).toMatch(/pattern/), expect(value).toContain('substring')
    • Arrays: expect(array).toContain(item), expect(array).toHaveLength(3)
    • Objects: expect(object).toHaveProperty('key', value)
    • Exceptions: expect(fn).toThrow(), expect(fn).toThrow(Error)
    • Mock functions: expect(mockFn).toHaveBeenCalled(), expect(mockFn).toHaveBeenCalledWith(arg1, arg2)

    Alternatives

    Compare before choosing