eggjs / eggjs/egg

刚初始化完成的项目controller单元测试404

Open
#5,368 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
19k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

### Your detail info about the Bug:

1. 使用egg-init --type=simple完成初始化
2. npm install 安装依赖
3. npm run test:local
/ 路由单元测试不通过, 返回响应码404

4. 修改单元测试用例如下后, 再次执行npm run test:local, 单元测试通过, 但此时npm run cov输出的单元测试覆盖率报告中, 不会将测试期间执行过的代码标记为已覆盖
```
const { strict: assert } = require('node:assert');
const path = require('node:path');
const { statSync } = require('node:fs');
const mm = require('egg-mock');

describe('test/app/controller/home.test.js', () => {
let app;
before(() => {
app = mm.cluster();
return app.ready();
});

it('should GET /', async () => {
return app.httpRequest()
.get('/')
.expect('hi, egg')
.expect(200);
});
});
```

### Reproduction Repo

### Node Version

v20.18.0

### Eggjs Version

3.17.5

### Plugin Name and its version

### Platform and its version

Windows 10 Pro(22H2)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.