Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mustang1988 opened this issue Nov 20, 2024 · 0 comments
Open

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

mustang1988 opened this issue Nov 20, 2024 · 0 comments

Comments

@mustang1988
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant