jest
Skill275 starsChanged 36 days agoApache-2.0View on GitHub
Jest testing best practices for JavaScript and TypeScript applications, covering test structure, mocking, and assertion patterns.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- anivar/jest-skilltheir own version, first seen Nov 3, 2026
- Mane087/IA-Skillstheir own version, first seen Nov 1, 2026
- G1Joshi/Agent-Skillstheir own version, first seen Oct 13, 2026
- christopher-buss/skillstheir own version, first seen May 13, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- G1Joshi/Agent-Skills★ 15same name
- anivar/jest-skill★ 9same name
- christopher-buss/skills★ 8same name
- Mane087/IA-Skills★ 4same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository264 other files it gives its agents.
- accessibility-a11ySkill
- alpine-jsSkill
- analytics-data-analysisSkill
- android-developmentSkill
- angular-developmentSkill
- angularSkill
- anime-jsSkill
- anthropic-claude-developmentSkill
- api-developmentSkill
- apollo-graphqlSkill
- aspnet-coreSkill
- astroSkill
- auth0-authenticationSkill
- autogen-developmentSkill
- automl-hyperparameter-optimizationSkill
- aws-developmentSkill
- azureSkill
- backend-developmentSkill
- bash-scriptingSkill
- beautifulsoup-parsingSkill
- bitbucket-workflowSkill
- blazorSkill
- blender-python-addonSkill
- blockchainSkill
- bootstrapSkill
- business-central-developmentSkill
- cheerio-parsingSkill
- chrome-extension-developmentSkill
- ci-cd-best-practicesSkill
- clean-architectureSkill
- clean-codeSkill
- clerk-authenticationSkill
- cloudflare-developmentSkill
- computer-vision-opencvSkill
- convexSkill
- cppSkill
- c-sharpSkill
- cssSkill
- cypressSkill
- data-analysis-jupyterSkill
- data-analystSkill
- data-jupyter-pythonSkill
- deep-learning-pythonSkill
- deep-learning-pytorchSkill
- deep-learningSkill
- deno-typescriptSkill
- design-systemsSkill
- devopsSkill
- django-pythonSkill
- django-rest-api-developmentSkill
- dockerSkill
- dotnetSkill
- drizzle-ormSkill
- drupal-developmentSkill
- elasticsearch-best-practicesSkill
- electron-developmentSkill
- elixirSkill
- embedded-stm32Skill
- esbuild-bundlerSkill
- ethereumSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
19 rules. 0 are common, 10 are distinctive, and 9 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
10
Distinctive
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Use descriptive test names that clearly explain expected behavior
- Distinctive: line 18
Follow the Arrange-Act-Assert (AAA) pattern in each test
- Distinctive: line 19
Keep tests focused on a single behavior or outcome
- Very specific: line 22
Use beforeEach and afterEach for test isolation
- Very specific: line 23
Use beforeAll and afterAll for expensive setup that can be shared
- Very specific: line 27
Use jest.mock() for module mocking
- Very specific: line 28
Use jest.fn() for function mocks
- Very specific: line 29
Use jest.spyOn() when you need to track calls but keep implementation
- Distinctive: line 31
Avoid over-mocking: test real behavior when feasible
- Distinctive: line 34
Use the most specific matcher available
- Very specific: line 35
Prefer toEqual for object comparison, toBe for primitives
- Very specific: line 36
Use toMatchSnapshot sparingly and with meaningful names
- Distinctive: line 40
Always return promises or use async/await in async tests
- Very specific: line 41
Use waitFor from testing libraries for async assertions
- Distinctive: line 46
Test edge cases and error conditions
- Very specific: line 47
Use --coverage flag to track coverage metrics
- Distinctive: line 50
Keep tests DRY but readable (prefer clarity over brevity)
- Distinctive: line 51
Test behavior, not implementation details
- Distinctive: line 53
Use factories or builders for test data creation
“Common” is measured: kept by at least 6 in 10 of the 4 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.
Files
Jest Testing Best Practices
You are an expert in JavaScript, TypeScript, and Jest testing.
Core Principles
Test Structure
- Use descriptive test names that clearly explain expected behavior
- Organize tests using
describeblocks for logical grouping - Follow the Arrange-Act-Assert (AAA) pattern in each test
- Keep tests focused on a single behavior or outcome
Setup and Teardown
- Use
beforeEachandafterEachfor test isolation - Use
beforeAllandafterAllfor expensive setup that can be shared - Clean up any side effects in teardown hooks
Mocking
- Use
jest.mock()for module mocking - Use
jest.fn()for function mocks - Use
jest.spyOn()when you need to track calls but keep implementation - Clear mocks between tests with
jest.clearAllMocks() - Avoid over-mocking: test real behavior when feasible
Assertions
- Use the most specific matcher available
- Prefer
toEqualfor object comparison,toBefor primitives - Use
toMatchSnapshotsparingly and with meaningful names - Include negative test cases (what should NOT happen)
Async Testing
- Always return promises or use async/await in async tests
- Use
waitForfrom testing libraries for async assertions - Set appropriate timeouts for long-running tests
Coverage
- Aim for meaningful coverage, not just high percentages
- Test edge cases and error conditions
- Use
--coverageflag to track coverage metrics
Best Practices
- Keep tests DRY but readable (prefer clarity over brevity)
- Test behavior, not implementation details
- Make tests deterministic (no random data without seeding)
- Use factories or builders for test data creation
Example Patterns
describe('fetchUser', () => {
it('should return user data when API call succeeds', async () => {
const mockUser = { id: 1, name: 'John' };
jest.spyOn(api, 'get').mockResolvedValue(mockUser);
const result = await fetchUser(1);
expect(result).toEqual(mockUser);
expect(api.get).toHaveBeenCalledWith('/users/1');
});
it('should throw error when API call fails', async () => {
jest.spyOn(api, 'get').mockRejectedValue(new Error('Not found'));
await expect(fetchUser(999)).rejects.toThrow('Not found');
});
});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
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.

