Creator · PramodDutta
Last updated · Sep 6, 2026
Unit testing skill using Jest for TypeScript and JavaScript, covering mocking, spies, snapshots, coverage, async testing, and custom matchers.
Sandbox only
Install targets
Codex install prompt
Install the "jest-unit" agent skill from https://github.com/PramodDutta/qaskills/tree/main/packs/qa-essentials/skills/jest-unit. Read its SKILL.md or equivalent instructions first, install only the files needed for this workspace, and summarize any required setup before using it. Skill purpose: Unit testing skill using Jest for TypeScript and JavaScript, covering mocking, spies, snapshots, coverage, async testing, and custom matchers. After the install attempt, report the result to https://www.openagentskill.com/api/agent/outcome with POST JSON {"event_id":"install_<unique-id>","skill_slug":"pramoddutta-jest-unit","task":"Install jest-unit","agent":"codex","outcome":"success","install_used":true}. Replace event_id with a unique value and outcome with success or failed. Report success only after the skill is installed and a minimal verification passes.Supply asset profile
Code review, repo analysis, testing, CI, GitHub, DevOps, and developer workflow skills.
Scenario
Coding agents
I need a coding agent that can understand a repository, edit code, and review pull requests.
Agent fit
Claude Code + CLI + Codex
Codex, Claude Code, Cursor, CLI, or custom agents.
Install
Ready
npx skills add PramodDutta/qaskills --skill jest-unit
Maintenance
fresh
8d since push
Risk
Needs review
Permission surface may require sandboxing
GitHub quality
217
71/100 Quality · 72/100 Trust
Coverage tags
Review notes
Permission surface may require sandboxing · In the provided jest.config.ts example, the key 'setupFilesAfterSetup' is not a valid Jest configuration option; it should be 'setupFilesAfterEnv'.
Agent adoption scorecard
These scores combine public repository metadata, OpenAgentSkill review signals, maintenance freshness, and install readiness. They are a shortlist signal, not a replacement for human review.
Quality
StrongSolid option that is likely worth shortlisting for production workflows.
Trust
Sandbox onlyUseful candidate with missing or mixed trust signals. Keep it in an isolated workspace until the outcome loop proves task fit.
Audit
Needs reviewA machine-readable review of install readiness, security metadata, maintenance, and adoption risk.
OpenAgentSkill Trust Score v5
Run only in a sandbox and compare close alternatives before using it for real work.
Stars
217 GitHub stars
Repo activity
217 stars, 23 forks
Maintenance
8d since push
License
MIT
Install
npx skills add PramodDutta/qaskills --skill jest-unit
Install safety
Agent-readable metadata
Use this block or the embedded JSON to decide whether an agent should install this skill, choose an alternative, or ask for human review first.
Suited tasks
Suited agents
Install decision
Trust and risk
Outcome loop
Install command
npx skills add PramodDutta/qaskills --skill jest-unitDo not use when
Alternative
168.6K Stars
npx skills add mattpocock/skills --skill code-review
Alternative
40.8K Stars
npx skills add appsmithorg/appsmith
Alternative
175.7K Stars
npx skills add mattpocock/skills --skill implement
Alternative
30.9K Stars
npx skills add vercel-labs/agent-skills --skill vercel-react-best-practices
Agent safety v2
Usable candidate, but the agent should surface permission and audit notes before installation.
Require human approval before installing into a real workspace.
medium
Skill likely fetches remote pages, APIs, repositories, or external services.
medium
Skill may read or write project files, documents, generated artifacts, or local workspace state.
medium
Skill may inspect schemas, query databases, or work with persistent stores.
Agent resolve plan
The Resolve API returns the selected skill, alternatives, safety policy, audit notes, install target, and copy-paste prompt an agent can follow without scraping this page.
Open JSON
/api/agent/resolve?task=Use%20jest-unit%20for%20an%20agent%20workflow&agent=codex&max_risk=medium
Resolve text
/api/agent/resolve?task=Use%20jest-unit%20for%20an%20agent%20workflow&agent=codex&max_risk=medium&format=text
Install handoff
/api/skills/pramoddutta-jest-unit/install
Agent should check
Copy prompt
Task: Use jest-unit in this workspace.
Resolve first: https://www.openagentskill.com/api/agent/resolve?task=Use%20jest-unit%20for%20an%20agent%20workflow&agent=codex&max_risk=medium
Review install handoff: https://www.openagentskill.com/api/skills/pramoddutta-jest-unit/install
Install command: npx skills add PramodDutta/qaskills --skill jest-unit
Before running it, summarize audit warnings, required permissions, and the fallback skill if install is risky.Agent handoff
Use the public install endpoint to fetch the command, safety checklist, target prompts, and canonical links for this skill.
Install handoff
/api/skills/pramoddutta-jest-unit/install
LLM text format
/api/skills/pramoddutta-jest-unit/install?format=text
Find alternatives
/api/skills/search?q=jest-unit&limit=3
Agent prompt
Use jest-unit for this task. Review https://www.openagentskill.com/api/skills/pramoddutta-jest-unit/install, then install with: npx skills add PramodDutta/qaskills --skill jest-unitRegistry metadata
This page exposes the same decision, trust, audit, use-case, and install signals through the Registry API, so agents can rank this skill without scraping the UI.
Manifest
/api/registry/manifest/pramoddutta-jest-unit
LLM text
/api/registry/manifest/pramoddutta-jest-unit?format=text
Install alias
/api/registry/install/pramoddutta-jest-unit
Recommend
/api/registry/recommend?task=Use%20jest-unit%20in%20an%20agent%20workflow&limit=3
Agent fit
Coding agents
Use-case tags
Platforms
Claude Code
Audit report
A machine-readable review of install readiness, security metadata, maintenance, and adoption risk.
Agent decision cockpit
Prototype with this skill first; keep a fallback candidate ready.
Role in stack
Fallback candidate
Primary fit
Coding agents
Trust label
Prototype first
Install path
Command ready
Use when
Evidence
review first
Implementation path
Trust profile
Useful candidate with missing or mixed trust signals. Keep it in an isolated workspace until the outcome loop proves task fit.
GitHub adoption
INFO217 GitHub stars
Stars/forks activity
CHECK217 stars, 23 forks; issue activity unavailable in current metadata
Recent maintenance
PASS8d since push
License clarity
PASSMIT
Good signals
Review before install
Recommended action
Run only in a sandbox and compare close alternatives before using it for real work.
Quality profile
Solid option that is likely worth shortlisting for production workflows.
Workflow fit
Build and ship code
I need a coding agent that can understand a repository, edit code, and review pull requests.
Verify behavior
I need my agent to test a web app, reproduce bugs, and verify fixes.
Operate web apps
I need my agent to control a browser, fill forms, and verify web app workflows.
Workflow fit
Inspect, patch, and verify code
A workflow for software agents that inspect repositories, review pull requests, generate tests, and turn findings into shippable patches.
Operate and verify web apps
A workflow for agents that navigate products, fill forms, take screenshots, and verify real user flows across web applications.
Turn skills into distribution
A workflow for turning newly indexed skills into SEO briefs, social drafts, comparison pages, and reusable publishing workflows.
Alternative shortlist
Similar skills that may fit this task.
Review a branch or diff against repository standards and the originating spec in two independent analysis passes.
Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
Implement work from an approved spec or ticket set, run focused and full tests, invoke code review, and commit the result to the current branch.
React and Next.js performance guidance for writing, reviewing, and refactoring production UI code.
--- name: jest-unit description: Unit testing skill using Jest for TypeScript and JavaScript, covering mocking, spies, snapshots, coverage, async testing, and custom matchers. license: MIT metadata: author: thetestingacademy version: 1.0.0 source: https://qaskills.sh/skills/thetestingacademy/jest-unit ---
# Jest Unit Testing Skill
You are an expert software engineer specializing in unit testing with Jest. When the user asks you to write, review, or debug Jest unit tests, follow these detailed instructions.
## Core Principles
1. **Test behavior, not implementation** -- Tests should verify what code does, not how it does it. 2. **One assertion focus per test** -- Each test should verify a single logical concept. 3. **Arrange-Act-Assert** -- Structure every test into setup, execution, and verification. 4. **Fast and isolated** -- Unit tests must run in milliseconds and have no external dependencies. 5. **Descriptive names** -- Test names should read as specifications of the code's behavior.
## Project Structure
``` src/ services/ user.service.ts user.service.test.ts order.service.ts order.service.test.ts utils/ validators.ts validators.test.ts formatters.ts formatters.test.ts models/ user.model.ts __mocks__/ axios.ts database.ts __tests__/ integration/ user-order.test.ts jest.config.ts ```
## Configuration
```typescript // jest.config.ts import type { Config } from 'jest';
const config: Config = { preset: 'ts-jest', testEnvironment: 'node', roots: ['<rootDir>/src'], testMatch: ['**/*.test.ts', '**/*.spec.ts'], collectCoverageFrom: [ 'src/**/*.ts', '!src/**/*.d.ts', '!src/**/*.test.ts', '!src/**/index.ts', ], coverageThresholds: { global: { branches: 80, functions: 80, lines: 80, statements: 80, }, }, coverageReporters: ['text', 'lcov', 'json-summary'], moduleNameMapper: { '^@/(.*)$': '<rootDir>/src/$1', }, setupFilesAfterSetup: ['<rootDir>/jest.setup.ts'], clearMocks: true, restoreMocks: true, };
export default config; ```
## Writing Tests
### Basic Test Structure
```typescript // validators.ts export function isValidEmail(email: string): boolean { const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; return regex.test(email); }
export function isStrongPassword(password: string): boolean { return ( password.length >= 8 && /[A-Z]/.test(password) && /[a-z]/.test(password) && /[0-9]/.test(password) && /[!@#$%^&*]/.test(password) ); } ```
```typescript // validators.test.ts import { isValidEmail, isStrongPassword } from './validators';
describe('isValidEmail', () => { it('should return true for valid email addresses', () => { expect(isValidEmail('user@example.com')).toBe(true); expect(isValidEmail('first.last@domain.co.uk')).toBe(true); expect(isValidEmail('user+tag@example.com')).toBe(true); });
it('should return false for invalid email addresses', () => { expect(isValidEmail('')).toBe(false); expect(isValidEmail('not-an-email')).toBe(false); expect(isValidEmail('@missing-local.com')).toBe(false); expect(isValidEmail('missing-at.com')).toBe(false); expect(isValidEmail('spaces here@bad.com')).toBe(false); }); });
describe('isStrongPassword', () => { it('should accept a strong password', () => { expect(isStrongPassword('SecurePass1!')).toBe(true); });
it('should reject passwords shorter than 8 characters', () => { expect(isStrongPassword('Ab1!')).toBe(false); });
it('should reject passwords without uppercase letters', () => { expect(isStrongPassword('lowercase1!')).toBe(false); });
it('should reject passwords without lowercase letters', () => { expect(isStrongPassword('UPPERCASE1!')).toBe(false); });
it('should reject passwords without numbers', () => { expect(isStrongPassword('NoNumbers!')).toBe(false); });
it('should reject passwords without special characters', () => { expect(isStrongPassword('NoSpecial1')).toBe(false); }); }); ```
### Testing Classes and Services
```typescript // user.service.ts import { UserRepository } from './user.repository'; import { EmailService } from './email.service';
export class UserService { constructor( private userRepo: UserRepository, private emailService: EmailService ) {}
async createUser(email: string, name: string): Promise<User> { const existing = await this.userRepo.findByEmail(email); if (existing) { throw new Error('User already exists'); }
const user = await this.userRepo.create({ email, name }); await this.emailService.sendWelcomeEmail(user.email, user.name); return user; }
async getUser(id: string): Promise<User | null> { return this.userRepo.findById(id); }
async deleteUser(id: string): Promise<void> { const user = await this.userRepo.findById(id); if (!user) { throw new Error('User not found'); } await this.userRepo.delete(id); } } ```
```typescript // user.service.test.ts import { UserService } from './user.service'; import { UserRepository } from './user.repository'; import { EmailService } from './email.service';
// Mock the dependencies jest.mock('./user.repository'); jest.mock('./email.service');
describe('UserService', () => { let userService: UserService; let mockUserRepo: jest.Mocked<UserRepository>; let mockEmailService: jest.Mocked<EmailService>;
beforeEach(() => { mockUserRepo = new UserRepository() as jest.Mocked<UserRepository>; mockEmailService = new EmailService() as jest.Mocked<EmailService>; userService = new UserService(mockUserRepo, mockEmailService); });
describe('createUser', () => { it('should create a user and send welcome email', async () => { const newUser = { id: '1', email: 'new@example.com', name: 'New User' }; mockUserRepo.findByEmail.mockResolvedValue(null); mockUserRepo.create.mockResolvedValue(newUser); mockEmailService.sendWelcomeEmail.mockResolvedValue(undefined);
const result = await userService.createUser('new@example.com', 'New User');
expect(result).toEqual(newUser); expect(mockUserRepo.findByEmail).toHaveBeenCalledWith('new@example.com'); expect(mockUserRepo.create).toHaveBeenCalledWith({ email: 'new@example.com', name: 'New User', }); expect(mockEmailService.sendWelcomeEmail).toHaveBeenCalledWith( 'new@example.com', 'New User' ); });
it('should throw error if user already exists', async () => { mockUserRepo.findByEmail.mockResolvedValue({ id: '1', email: 'existing@example.com', name: 'Existing', });
await expect( userService.createUser('existing@example.com', 'Duplicate') ).rejects.toThrow('User already exists');
expect(mockUserRepo.create).not.toHaveBeenCalled(); expect(mockEmailService.sendWelcomeEmail).not.toHaveBeenCalled(); }); });
describe('getUser', () => { it('should return user when found', async () => { const user = { id: '1', email: 'user@example.com', name: 'User' }; mockUserRepo.findById.mockResolvedValue(user);
const result = await userService.getUser('1');
expect(result).toEqual(user); expect(mockUserRepo.findById).toHaveBeenCalledWith('1'); });
it('should return null when user not found', async () => { mockUserRepo.findById.mockResolvedValue(null);
const result = await userService.getUser('nonexistent');
expect(result).toBeNull(); }); });
describe('deleteUser', () => { it('should delete an existing user', async () => { const user = { id: '1', email: 'user@example.com', name: 'User' }; mockUserRepo.findById.mockResolvedValue(user); mockUserRepo.delete.mockResolvedValue(undefined);
await userService.deleteUser('1');
expect(mockUserRepo.delete).toHaveBeenCalledWith('1'); });
it('should throw error when deleting non-existent user', async () => { mockUserRepo.findById.mockResolvedValue(null);
await expect(userService.deleteUser('nonexistent')).rejects.toThrow( 'User not found' ); }); }); }); ```
## Mocking Patterns
### Manual Mocks
```typescript // __mocks__/axios.ts const axios = { get: jest.fn(() => Promise.resolve({ data: {} })), post: jest.fn(() => Promise.resolve({ data: {} })), put: jest.fn(() => Promise.resolve({ data: {} })), delete: jest.fn(() => Promise.resolve({ data: {} })), create: jest.fn(function () { return axios; }), interceptors: { request: { use: jest.fn() }, response: { use: jest.fn() }, }, };
export default axios; ```
### Spying on Methods
```typescript it('should call console.error on failure', async () => { const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
await processData(invalidData);
expect(consoleSpy).toHaveBeenCalledWith( expect.stringContaining('Processing failed') );
consoleSpy.mockRestore(); }); ```
### Mocking Timers
```typescript describe('Debounce function', () => { beforeEach(() => { jest.useFakeTimers(); });
afterEach(() => { jest.useRealTimers(); });
it('should debounce function calls', () => { const fn = jest.fn(); const debounced = debounce(fn, 300);
debounced(); debounced(); debounced();
expect(fn).not.toHaveBeenCalled();
jest.advanceTimersByTime(300);
expect(fn).toHaveBeenCalledTimes(1); });
it('should reset timer on subsequent calls', () => { const fn = jest.fn(); const debounced = debounce(fn, 300);
debounced(); jest.advanceTimersByTime(200); debounced(); // resets the timer jest.advanceTimersByTime(200);
expect(fn).not.toHaveBeenCalled();
jest.advanceTimersByTime(100); expect(fn).toHaveBeenCalledTimes(1); }); }); ```
### Mocking Modules
```typescript // Mock an entire module jest.mock('fs', () => ({ readFileSync: jest.fn(() => 'mocked content'), writeFileSync: jest.fn(), existsSync: jest.fn(() => true), }));
// Mock with factory function jest.mock('./config', () => ({ getConfig: () => ({ apiUrl: 'http://test-api.example.com', timeout: 1000, }), }));
// Partial mock -- keep some original implementations jest.mock('./utils', () => ({ ...jest.requireActual('./utils'), fetchData: jest.fn(), })); ```
## Async Testing
```typescript // Testing resolved promises it('should resolve with data', async () => { const result = await fetchUser('1'); expect(result.name).toBe('John'); });
// Testing rejected promises it('should reject with error', async () => { await expect(fetchUser('invalid')).rejects.toThrow('Not found'); });
// Testing callbacks it('should call callback with data', (done) => { fetchUserCallback('1', (err, data) => { expect(err).toBeNull(); expect(data.name).toBe('John'); done(); }); });
// Testing event emitters it('should emit data event', (done) => { const emitter = new DataEmitter(); emitter.on('data', (payload) => { expect(payload).toEqual({ id: 1 }); done(); }); emitter.start(); }); ```
## Snapshot Testing
```typescript // Component snapshot it('should render correctly', () => { const output = renderComponent({ name: 'Test', count: 5 }); expect(output).toMatchSnapshot(); });
// Inline snapshot it('should format user display name', () => { const result = formatDisplayName({ first: 'John', last: 'Doe' }); expect(result).toMatchInlineSnapshot(`"John Doe"`); });
// Custom serializer expect.addSnapshotSerializer({ test: (val) => val instanceof Date, print: (val) => `Date(${(val as Date).toISOString()})`, }); ```
## Custom Matchers
```typescript // jest.setup.ts expect.extend({ toBeWithinRange(received: number, floor: number, ceiling: number) { const pass = received >= floor && received <= ceiling; return { pass, message: () =>
Source provenance
Decision snapshot
recent repository activity
Audit
Install and adoption review
Agent-proven evidence
Outcome reports after resolve, review, install, and one narrow run.
No agent outcome data yet. The first agent run can report success, setup needs, risk blocks, failure, or not-relevant through /api/agent/outcome.
Install
Free and open source. Review the report before installing into production agents.
Growth loop
Scenario-led draft for jest-unit, ready for a manual X post.
A practical pick for source-backed research: jest-unit: Unit testing skill using Jest for TypeScript and JavaScript, covering mocking, spies, snapshots, coverage, async testing, a... 217 stars https://www.openagentskill.com/skills/pramoddutta-jest-unit?ref=x
Listing + install path for jest-unit: https://www.openagentskill.com/skills/pramoddutta-jest-unit?ref=x Install: npx skills add PramodDutta/qaskills --skill jest-unit
Listing source
This listing was indexed from public sources and is not marked official until a maintainer claim is approved.
Attribution links to the public repository or creator profile. Creators can claim the listing to update ownership signals.
Claim this skillOwner claim
This Registry indexed listing is attributed to PramodDutta but is not marked official yet. Claim it to add a verified owner signal and make future launch, install, and audit updates easier to trust.
Creator backlink kit
Show the canonical listing, current trust and audit signals, and real Agent-Proven evidence where developers evaluate the repository.
[](https://www.openagentskill.com/skills/pramoddutta-jest-unit?ref=github&utm_source=github&utm_medium=referral&utm_campaign=creator_badge)
[](https://www.openagentskill.com/skills/pramoddutta-jest-unit?ref=github&utm_source=github&utm_medium=referral&utm_campaign=creator_badge)
[](https://www.openagentskill.com/skills/pramoddutta-jest-unit/audit)
[](https://www.openagentskill.com/skills/pramoddutta-jest-unit?ref=github&utm_source=github&utm_medium=referral&utm_campaign=creator_badge)PramodDutta
@pramoddutta
Share whether this skill looks useful for your agent workflow. Aggregated feedback improves rankings over time.
Sandbox only
Code Review
Review a branch or diff against repository standards and the originating spec in two independent analysis passes.
168.6K StarsAppsmith
Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
40.8K StarsImplement
Implement work from an approved spec or ticket set, run focused and full tests, invoke code review, and commit the result to the current branch.
175.7K StarsVercel React Best Practices
React and Next.js performance guidance for writing, reviewing, and refactoring production UI code.
30.9K StarsPermission surface
secrets or environment access, filesystem or document access
Agent outcomes
No agent outcome data yet
Docs
Strong README/SKILL.md context
Risk summary
Install readiness