Loading...
Loading...
Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies, test structure, and common patterns.
npx skill4agent add github/awesome-copilot javascript-typescript-jest.test.ts.test.js__tests__describe('Component/Function/Class', () => { it('should do something', () => {}) })jest.mock()jest.spyOn()mockImplementation()mockReturnValue()jest.resetAllMocks()afterEachresolvesrejectsjest.setTimeout()userEventfireEventexpect(value).toBe(expected)expect(value).toEqual(expected)expect(value).toBeTruthy()expect(value).toBeFalsy()expect(value).toBeGreaterThan(3)expect(value).toBeLessThanOrEqual(3)expect(value).toMatch(/pattern/)expect(value).toContain('substring')expect(array).toContain(item)expect(array).toHaveLength(3)expect(object).toHaveProperty('key', value)expect(fn).toThrow()expect(fn).toThrow(Error)expect(mockFn).toHaveBeenCalled()expect(mockFn).toHaveBeenCalledWith(arg1, arg2)