Skip to main content
skill GitHub Copilot official · GitHub

javascript-typescript-jest — GitHub Copilot testing skill

This skill guides GitHub Copilot in writing JavaScript and TypeScript tests with Jest. Use it when you want concrete patterns for mocks, async tests, and test organization.

Install into GitHub Copilot · Skills CLI (Vercel) All methods and platforms ↓
npx skills add github/awesome-copilot --skill javascript-typescript-jest
Open on GitHub

What javascript-typescript-jest does

The skill recommends .test.ts or .test.js filenames and placing tests beside the code under test or in an __tests__ directory. It covers grouping cases with describe and it, common Jest matchers, exception checks, and focused snapshots.

For isolation, it describes jest.mock() and jest.spyOn(), setting mock behavior with mockImplementation() or mockReturnValue(), and clearing mocks in afterEach. Async tests should return promises or use async/await; resolves and rejects handle promise outcomes. Slow tests can use jest.setTimeout().

For React, the skill favors React Testing Library over Enzyme and suggests querying by accessibility role, label, or text. It provides testing guidance, not project setup. Install it when Copilot needs Jest-specific direction; skip it if your project does not use Jest.

What it helps with

  • organize test files alongside the code they cover
  • isolate tests from API or database dependencies with mocks
  • check promise results and rejected async calls
  • query React components by accessible roles and labels
  • keep snapshots focused and reviewable

Example prompts for the agent

  • Write Jest tests for this function using descriptive `describe` and `it` blocks.
  • Mock the external API with `jest.mock()` and reset mocks after each test.
  • Test this React component with React Testing Library and query by accessibility role.

How to install javascript-typescript-jest

1Skills CLI (Vercel)

npx skills add github/awesome-copilot --skill javascript-typescript-jest

2GitHub CLI

gh skill install github/awesome-copilot javascript-typescript-jest

3Manually: put the files in place

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

From the same set554

The whole set →
git-commit official github This skill reviews Git changes, stages related files, and creates Conventional Commits. Use it when you want an agent to make one commit or split work into separate commits. GitHub Copilot 47,165installs excalidraw-diagram-generator official github Turn a plain-language description into an Excalidraw diagram. Useful for mapping processes, system structure, and relationships between entities. GitHub Copilot 31,639installs multi-stage-dockerfile official github This skill guides GitHub Copilot in writing multi-stage Dockerfiles for different languages and frameworks. Use it when the final runtime image should contain fewer build dependencies. GitHub Copilot 29,688installs documentation-writer official github Skill that turns the agent into a technical writer following the Diátaxis framework: tutorials, how-to guides, reference, and explanation. Proposes structure before writing. GitHub Copilot 27,757installs prd official github Turns a feature idea into a structured PRD with user stories, technical requirements, and risks. Use it when planning a software feature or an AI-powered one. GitHub Copilot 24,035installs refactor official github This skill reshapes existing code without changing its external behavior. Use it for gradual cleanup of large functions, duplication, weak types, and code smells. GitHub Copilot 22,321installs java-springboot official github Gives GitHub Copilot Spring Boot development practices, from project layout to tests and security. Use it when writing or reviewing Java application code. GitHub Copilot 21,272installs create-readme official github This skill reviews a project and creates a structured README.md. Use it when the repository needs clear documentation based on its actual files and code. GitHub Copilot 19,081installs

Similar

csharp-testing affaan-m A skill that gives your agent C# and .NET testing patterns: xUnit, FluentAssertions, mocks, integration tests. Claude Code CX Codex Cursor +1 4,400installs python-testing-patterns Seth Hobson This skill guides Python testing with pytest, fixtures and mocks. Use it when building a test suite or tracking down failing checks. Claude Code CX Codex Cursor 36,943installs python-performance-optimization Seth Hobson This skill profiles Python code to locate CPU and memory bottlenecks. Use it when an application responds slowly or consumes too many resources. Claude Code CX Codex Cursor 35,675installs flow react Runs Flow type checking in a React project and reports errors with file locations. Useful when you edit code and don't want to look up the right renderer flag each time. Claude Code CX Codex Cursor +1 1,100installs migrate-to-shoehorn Matt Pocock Replaces as type assertions in tests with helpers from @total-typescript/shoehorn. Use it when tests need partial objects or deliberately invalid data. Claude Code 475,388installs write-swift emilkowalski This skill guides Swift coding, reviews, and migrations using the language’s current practices. Use it to investigate concurrency errors, hangs, data races, or retain cycles. Claude Code CX Codex Cursor +1 117,500installs megacave JuliusBrussee Switches agent responses to Classical Chinese (wenyan) to reduce terminal output. Activated via /megacave or /caveman wenyan. Claude Code CX Codex Cursor +1 24,400installs find-docs upstash Pulls up-to-date documentation, API references and code examples for any library through the Context7 CLI. Useful when the model's training data lags behind the API. Claude Code CX Codex Cursor +1 9,400installs

Questions about javascript-typescript-jest

How do I install javascript-typescript-jest in GitHub Copilot?

Run npx skills add github/awesome-copilot --skill javascript-typescript-jest or gh skill install github/awesome-copilot javascript-typescript-jest.

What does javascript-typescript-jest do?

It gives Copilot patterns for JavaScript and TypeScript tests with Jest, including test structure, mocking, async checks, and matchers.

What does the skill recommend for React component tests?

It recommends React Testing Library over Enzyme, checking user behavior and accessibility, and querying by role, label, or text. Use userEvent for interactions rather than fireEvent.

Source text

SKILL.md · MIT
---
name: javascript-typescript-jest
description: 'Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies, test structure, and common patterns.'
---

### 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)`

© github · MIT · github/awesome-copilot

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor