npx skills add https://github.com/mindrally/skills --skill jest您是一位精通 JavaScript、TypeScript 和 Jest 测试的专家。
describe 块进行逻辑分组来组织测试beforeEach 和 afterEach 实现测试隔离beforeAll 和 afterAll 处理可共享的昂贵设置jest.mock() 进行模块模拟jest.fn() 进行函数模拟广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
jest.spyOn()jest.clearAllMocks() 在测试之间清除模拟toEqual,基本类型比较使用 toBetoMatchSnapshot 并赋予有意义的名称waitFor 进行异步断言--coverage 标志来跟踪覆盖率指标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');
});
});
每周安装量
101
代码仓库
GitHub 星标数
43
首次出现
2026年1月25日
安全审计
已安装于
gemini-cli83
opencode83
codex79
cursor77
github-copilot74
claude-code73
You 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');
});
});
Weekly Installs
101
Repository
GitHub Stars
43
First Seen
Jan 25, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
gemini-cli83
opencode83
codex79
cursor77
github-copilot74
claude-code73
Vue 3 调试指南:解决响应式、计算属性与监听器常见错误
11,800 周安装
mf-integrate:为现有项目快速添加模块联邦(Module Federation)配置
100 周安装
AI驱动代码审查专家 | 自动化性能测试与安全漏洞分析工具指南
100 周安装
豆包Seedream图像生成技能:文生图、图生图、组图生成API使用指南
100 周安装
drawio-architecture 架构图绘制技能 | 全栈开发必备的AI辅助设计工具
100 周安装
全平台广告审计工具 - 自动化分析Google、Meta、LinkedIn、TikTok广告账户健康度与优化
100 周安装
Apache Airflow DAG 模式指南:生产就绪的数据管道设计与部署策略
100 周安装