You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Jest+Express.js中遇到GitHubActionsReporter错误的原因排查

Jest测试报错:Cannot find module './GitHubActionsReporter'

问题说明

用Jest测试Express.js接口时,执行测试抛出以下错误:

Error: Cannot find module './GitHubActionsReporter'

可复现操作步骤

  • 执行命令:npm install --save-dev jest
  • 创建sum.js文件,代码如下:
function sum(a, b) {
  return a + b;
}
module.exports = sum;
  • 创建sum.test.js文件,代码如下:
const sum = require('./sum');
    
test('adds 1 + 2 to equal 3', () => {
  expect(sum(1, 2)).toBe(3);
});
  • 在package.json中添加配置:
{
  "scripts": {
    "test": "jest"
  }
}
  • 执行命令:npm test

内容的提问来源于stack exchange,提问作者Leo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 07:05:27