{"id":"06338177-72b6-44bf-8d29-6bc64537fdd2","shortId":"aSU3uq","kind":"skill","title":"javascript-typescript-jest","tagline":"Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies, test structure, and common patterns.","description":"### Test Structure\n- Name test files with `.test.ts` or `.test.js` suffix\n- Place test files next to the code they test or in a dedicated `__tests__` directory\n- Use descriptive test names that explain the expected behavior\n- Use nested describe blocks to organize related tests\n- Follow the pattern: `describe('Component/Function/Class', () => { it('should do something', () => {}) })`\n\n### Effective Mocking\n- Mock external dependencies (APIs, databases, etc.) to isolate your tests\n- Use `jest.mock()` for module-level mocks\n- Use `jest.spyOn()` for specific function mocks\n- Use `mockImplementation()` or `mockReturnValue()` to define mock behavior\n- Reset mocks between tests with `jest.resetAllMocks()` in `afterEach`\n\n### Testing Async Code\n- Always return promises or use async/await syntax in tests\n- Use `resolves`/`rejects` matchers for promises\n- Set appropriate timeouts for slow tests with `jest.setTimeout()`\n\n### Snapshot Testing\n- Use snapshot tests for UI components or complex objects that change infrequently\n- Keep snapshots small and focused\n- Review snapshot changes carefully before committing\n\n### Testing React Components\n- Use React Testing Library over Enzyme for testing components\n- Test user behavior and component accessibility\n- Query elements by accessibility roles, labels, or text content\n- Use `userEvent` over `fireEvent` for more realistic user interactions\n\n## Common Jest Matchers\n- Basic: `expect(value).toBe(expected)`, `expect(value).toEqual(expected)`\n- Truthiness: `expect(value).toBeTruthy()`, `expect(value).toBeFalsy()`\n- Numbers: `expect(value).toBeGreaterThan(3)`, `expect(value).toBeLessThanOrEqual(3)`\n- Strings: `expect(value).toMatch(/pattern/)`, `expect(value).toContain('substring')`\n- Arrays: `expect(array).toContain(item)`, `expect(array).toHaveLength(3)`\n- Objects: `expect(object).toHaveProperty('key', value)`\n- Exceptions: `expect(fn).toThrow()`, `expect(fn).toThrow(Error)`\n- Mock functions: `expect(mockFn).toHaveBeenCalled()`, `expect(mockFn).toHaveBeenCalledWith(arg1, arg2)`","tags":["javascript","typescript","jest","awesome","copilot","github","agent-skills","agents","custom-agents","github-copilot","hacktoberfest","prompt-engineering"],"capabilities":["skill","source-github","skill-javascript-typescript-jest","topic-agent-skills","topic-agents","topic-awesome","topic-custom-agents","topic-github-copilot","topic-hacktoberfest","topic-prompt-engineering"],"categories":["awesome-copilot"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/github/awesome-copilot/javascript-typescript-jest","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add github/awesome-copilot","source_repo":"https://github.com/github/awesome-copilot","install_from":"skills.sh"}},"qualityScore":"0.700","qualityRationale":"deterministic score 0.70 from registry signals: · indexed on github topic:agent-skills · 33270 github stars · SKILL.md body (2,043 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T18:52:15.472Z","embedding":null,"createdAt":"2026-04-18T20:25:15.431Z","updatedAt":"2026-05-18T18:52:15.472Z","lastSeenAt":"2026-05-18T18:52:15.472Z","tsv":"'/pattern':232 '3':223,227,245 'access':181,185 'aftereach':112 'alway':116 'api':77 'appropri':132 'arg1':268 'arg2':269 'array':237,239,243 'async':114 'async/await':121 'basic':203 'behavior':54,104,178 'best':5 'block':58 'care':161 'chang':151,160 'code':37,115 'commit':163 'common':19,200 'complex':148 'compon':146,166,175,180 'component/function/class':67 'content':190 'databas':78 'dedic':43 'defin':102 'depend':76 'describ':57,66 'descript':47 'directori':45 'effect':72 'element':183 'enzym':172 'error':259 'etc':79 'except':252 'expect':53,204,207,208,211,213,216,220,224,229,233,238,242,247,253,256,262,265 'explain':51 'extern':75 'file':25,33 'fireev':194 'fn':254,257 'focus':157 'follow':63 'function':95,261 'includ':13 'infrequ':152 'interact':199 'isol':81 'item':241 'javascript':2 'javascript-typescript-jest':1 'javascript/typescript':9 'jest':4,12,201 'jest.mock':85 'jest.resetallmocks':110 'jest.settimeout':138 'jest.spyon':92 'keep':153 'key':250 'label':187 'level':89 'librari':170 'matcher':128,202 'mock':14,73,74,90,96,103,106,260 'mockfn':263,266 'mockimplement':98 'mockreturnvalu':100 'modul':88 'module-level':87 'name':23,49 'nest':56 'next':34 'number':219 'object':149,246,248 'organ':60 'pattern':20,65 'place':31 'practic':6 'promis':118,130 'queri':182 'react':165,168 'realist':197 'reject':127 'relat':61 'reset':105 'resolv':126 'return':117 'review':158 'role':186 'set':131 'skill' 'skill-javascript-typescript-jest' 'slow':135 'small':155 'snapshot':139,142,154,159 'someth':71 'source-github' 'specif':94 'strategi':15 'string':228 'structur':17,22 'substr':236 'suffix':30 'syntax':122 'test':10,16,21,24,32,39,44,48,62,83,108,113,124,136,140,143,164,169,174,176 'test.js':29 'test.ts':27 'text':189 'timeout':133 'tobe':206 'tobefalsi':218 'tobegreaterthan':222 'tobelessthanorequ':226 'tobetruthi':215 'tocontain':235,240 'toequal':210 'tohavebeencal':264 'tohavebeencalledwith':267 'tohavelength':244 'tohaveproperti':249 'tomatch':231 'topic-agent-skills' 'topic-agents' 'topic-awesome' 'topic-custom-agents' 'topic-github-copilot' 'topic-hacktoberfest' 'topic-prompt-engineering' 'tothrow':255,258 'truthi':212 'typescript':3 'ui':145 'use':11,46,55,84,91,97,120,125,141,167,191 'user':177,198 'userev':192 'valu':205,209,214,217,221,225,230,234,251 'write':8","prices":[{"id":"905e84df-ad62-4e20-b2dc-cd0a2c5a0caf","listingId":"06338177-72b6-44bf-8d29-6bc64537fdd2","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"github","category":"awesome-copilot","install_from":"skills.sh"},"createdAt":"2026-04-18T20:25:15.431Z"}],"sources":[{"listingId":"06338177-72b6-44bf-8d29-6bc64537fdd2","source":"github","sourceId":"github/awesome-copilot/javascript-typescript-jest","sourceUrl":"https://github.com/github/awesome-copilot/tree/main/skills/javascript-typescript-jest","isPrimary":false,"firstSeenAt":"2026-04-18T21:49:59.234Z","lastSeenAt":"2026-05-18T18:52:15.472Z"},{"listingId":"06338177-72b6-44bf-8d29-6bc64537fdd2","source":"skills_sh","sourceId":"github/awesome-copilot/javascript-typescript-jest","sourceUrl":"https://skills.sh/github/awesome-copilot/javascript-typescript-jest","isPrimary":true,"firstSeenAt":"2026-04-18T20:25:15.431Z","lastSeenAt":"2026-05-07T22:40:16.826Z"}],"details":{"listingId":"06338177-72b6-44bf-8d29-6bc64537fdd2","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"github","slug":"javascript-typescript-jest","github":{"repo":"github/awesome-copilot","stars":33270,"topics":["agent-skills","agents","ai","awesome","custom-agents","github-copilot","hacktoberfest","prompt-engineering"],"license":"mit","html_url":"https://github.com/github/awesome-copilot","pushed_at":"2026-05-18T01:26:59Z","description":"Community-contributed instructions, agents, skills, and configurations to help you make the most of GitHub Copilot.","skill_md_sha":"9552d7cb7b741148db4639124329fe3eb061354f","skill_md_path":"skills/javascript-typescript-jest/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/github/awesome-copilot/tree/main/skills/javascript-typescript-jest"},"layout":"multi","source":"github","category":"awesome-copilot","frontmatter":{"name":"javascript-typescript-jest","description":"Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies, test structure, and common patterns."},"skills_sh_url":"https://skills.sh/github/awesome-copilot/javascript-typescript-jest"},"updatedAt":"2026-05-18T18:52:15.472Z"}}