<!-- 如果你是新手,请务必仔细阅读:[如何正确的提出一个 Issue](https://github.com/eggjs/egg/issues/3310)。 感谢您向我们反馈问题,为了高效的解决问题,我们期望你能提供以下信息: --> ## 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 1. `npm install` 1. `npm run 'test-cluster'` 2. 在 chrome 访问 localhost:17001 3. 出现 `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" ``` 謝謝
What happens?
使用 Typescript + egg-mock 的 mm.cluster 起动後,出现
nodejs.Error: Please set config.keys first错误我知道
npm start前需要npm tsc,这样起动是没问题的。但 mm.cluster 跑测试就会出现问题。最小可复现仓库
复现步骤,错误日志以及相关配置
npm installnpm run 'test-cluster'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
相关环境信息
謝謝