Jest testing best practices for JavaScript and TypeScript applications, covering test structure, mocking, and assertion patterns.
42
41%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./jest/SKILL.mdYou are an expert in JavaScript, TypeScript, and Jest testing.
describe blocks for logical groupingbeforeEach and afterEach for test isolationbeforeAll and afterAll for expensive setup that can be sharedjest.mock() for module mockingjest.fn() for function mocksjest.spyOn() when you need to track calls but keep implementationjest.clearAllMocks()toEqual for object comparison, toBe for primitivestoMatchSnapshot sparingly and with meaningful nameswaitFor from testing libraries for async assertions--coverage flag to track coverage metricsdescribe('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');
});
});jest/SKILL.md
05a7130
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.