javascript-typescript-jest

Jest testing best practices for JavaScript and TypeScript projects with mocking, async handling, and React patterns. Organize tests with descriptive names in nested describe blocks, using .test.ts / .test.js files placed alongside source code or in __tests__ directories Mock external dependencies with jest.mock() , jest.spyOn() , and mockImplementation() , resetting between tests to prevent state leakage Handle async code with promises, async/await , and resolves / rejects matchers; set timeouts for slow tests Test React components with React Testing Library, querying by accessibility roles and labels, and using userEvent for realistic interactions Includes 20+ common matchers covering truthiness, numbers, strings, arrays, objects, exceptions, and mock function assertions

INSTALLATION
npx skills add https://github.com/github/awesome-copilot --skill javascript-typescript-jest
Run in your project or agent environment. Adjust flags if your CLI version differs.

SKILL.md

$2a

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)
BrowserAct

Let your agent run on any real-world website

Bypass CAPTCHA & anti-bot for free. Start local, scale to cloud.

Explore BrowserAct Skills →

Stop writing automation&scrapers

Install the CLI. Run your first Skill in 30 seconds. Scale when you're ready.

Start free
free · no credit card