github avatar

Javascript Typescript Jest

The javascript-typescript-jest skill provides best practices for writing unit tests in JavaScript and TypeScript projects using the Jest testing framework, covering test structure, mocking strategies, async testing, and React component testing. It's designed for developers building applications with Jest who need guidance on organizing tests, isolating dependencies through mocking, and using appropriate matchers and testing patterns. This skill solves the problem of writing ineffective or poorly organized tests by establishing conventions for test naming, file placement, mock management, and testing different code types.

skills.sh installs
14.5K
GitHub stars
41K
last updated
Aug 21, 2026

Install

$ npx -y skills add github/awesome-copilot --skill javascript-typescript-jest --agent claude-code

Installs into .claude/skills of the current project.

Files

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

Sponsors

Details

Repository
github.com/github/awesome-copilot
Categories
Testing & QA, Git & Pull Requests, Documentation, AI & Agent Building

More from github/awesome-copilot

All 318
1github avatarwebapp-testinggithub/awesome-copilotToolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing br12.5Kskills.sh installs
2wshobson avatarbats-testing-patternswshobson/agentsMaster Bash Automated Testing System (Bats) for comprehensive shell script testing. Use when writing tests for shell scripts, CI/CD pipelines, or requiring test11.4Kskills.sh installs
3wshobson avatarweb3-testingwshobson/agentsTest smart contracts comprehensively using Hardhat and Foundry with unit tests, integration tests, and mainnet forking. Use when testing Solidity contracts, set11.2Kskills.sh installs
4hashicorp avatarterraform-testhashicorp/agent-skillsComprehensive guide for writing and running Terraform tests. Use when creating test files (.tftest.hcl), writing test scenarios with run blocks, validating infr9.2Kskills.sh installs
5affaan-m avatarbrowser-qaaffaan-m/eccUse this skill to automate visual testing and UI interaction verification using browser automation after deploying features.6Kskills.sh installs
6affaan-m avatarcpp-testingaffaan-m/eccUse only when writing/updating/fixing C++ tests, configuring GoogleTest/CTest, diagnosing failing or flaky tests, or adding coverage/sanitizers.5.8Kskills.sh installs