Skip to content

Typescript + egg-mock cluster 報錯 #3930

@alickmail

Description

@alickmail

What happens?

使用 Typescript + egg-mock 的 mm.cluster 起动後,出现 nodejs.Error: Please set config.keys first 错误

我知道 npm start 前需要 npm tsc,这样起动是没问题的。但 mm.cluster 跑测试就会出现问题。

最小可复现仓库

请使用 npm init egg --type=simple bug 创建,并上传到你的 GitHub 仓库
https://github.com/alickmail/typescript-eggjs-mm-cluster-error

复现步骤,错误日志以及相关配置

  1. git clone https://github.com/alickmail/typescript-eggjs-mm-cluster-error
  2. npm install
  3. npm run 'test-cluster'
  4. 在 chrome 访问 localhost:17001
  5. 出现 nodejs.Error: Please set config.keys first 错误

使用 egg-mock cluster 的原因是 egg-socket.io 必须使用 cluster 模式才能成功测试

參考:

https://github.com/eggjs/egg-socket.io/blob/master/test/io.test.js

相关环境信息

  • 操作系统:macOS Mojave (Mac Pro)
  • Node 版本:v10.13.0
  • Egg 版本
 "egg": "^2.6.1",
 "egg-scripts": "^2.6.0"
 "egg-ci": "^1.8.0",
 "egg-bin": "^4.11.0",
 "egg-mock": "^3.16.0",
 "tslib": "^1.9.0",
 "tslint": "^5.0.0",
 "tslint-config-egg": "^1.0.0",
 "typescript": "^3.0.0"

謝謝

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions