-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
docs: add core/development.md #214
Conversation
Current coverage is 97.48% (diff: 100%)
|
PR title and file name typo: |
d4c5a12
to
68d146f
Compare
```json | ||
{ | ||
"devDependencies": { | ||
"egg-bin": "1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用 ^ 吧
} | ||
``` | ||
|
||
这样我们就可以通过 `npm run test` 命令运行单元测试。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm test
|
||
### 测试框架 | ||
|
||
集成了 [mocha](https://mochajs.org/),无需再手动依赖,直接书写 mocha 用例,并且通过 [thunk-mocha](https://npmjs.com/thunk-mocha) 模块扩展了多种用例书写方式,例如 generator 函数,async await 等。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个和下面的是不是直接链到 unittest.md 去
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我这里写的比较简单,然后上面加个链接到 unittest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
单测我觉得全都可以放到 unittest.md
这个文档可以讲讲本地启动的原理,和线上有什么区别,debug 方式等等
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
下面有的,环境配置
我们在编写用例时往往想单独执行正在编写的用例,可以通过以下方式指定特定用例文件: | ||
|
||
```bash | ||
TESTS=test/x.test.js egg-bin test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
支持 glob
|
||
为了提升研发体验,我们提供了便捷的方式在本地进行开发、调试、单元测试等。 | ||
|
||
在这里我们需要使用到 [egg-bin](https://github.com/eggjs/egg-bin) 模块。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
强调下只在本地开发和单元测试使用,部署方法链接到 advanced/deployment.md
|
||
在这里我们需要使用到 [egg-bin](https://github.com/eggjs/egg-bin) 模块。 | ||
|
||
首先,我们需要把 `egg-bin` 模块作为 `devDependency` 引入到 `package.json`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
devDependencies
@atian25 之后来补充下 IDE 的 debug? |
68d146f
to
e760c85
Compare
改好了 @popomore |
再来一个人看 |
|
||
## 更多 | ||
|
||
如果想了解更多本地开发相关的内容,例如为你的团队定制一个本地开发工具,请参考 [egg-bin](https://github.com/eggjs/egg-bin)。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里也可以发挥一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个太深入了,先 ref 插件文档吧,插件文档里有描述。后续有需求再加。
|
||
![image](https://cloud.githubusercontent.com/assets/456108/21771461/66bb5232-d6c2-11e6-8d2c-9076a5e414b0.png) | ||
|
||
### 使用 debug 模块 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我们是推荐用 debug 模块,还是直接 this.logger.debug
?
我偏向后者
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
讨论了一下:
- 框架和插件用 debug 模块
- 业务用 logger
e760c85
to
08d422a
Compare
增加了 logger 的说明 |
@gxcsoccer done |
@gxcsoccer 再确认下 |
08d422a
to
b0d49c3
Compare
|
||
### 使用 debug 模块调试 | ||
|
||
[debug](https://www.npmjs.com/package/npm) 模块是 node 社区广泛使用的 debug 工具,很多模块都使用它模块打印调试信息,egg 社区也广泛采用这一机制打印 debug 信息,__推荐在框架和插件开发中使用它。__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f30804f
to
1cd9899
Compare
|
||
### 使用 logger 模块调试 | ||
|
||
框架内置了[日志](./logger.md)功能,使用 `logger.debug()` 输出调试信息,__推荐在业务代码中使用它。__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应用代码
本地启动应用默认监听 7001 端口,可指定其他端口,例如: | ||
|
||
```bash | ||
egg-bin dev --port 8888 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm run dev -- --port 8888
我们在编写用例时往往想单独执行正在编写的用例,可以通过以下方式指定特定用例文件: | ||
|
||
```bash | ||
TESTS=test/x.test.js egg-bin test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TEST=test/x.test.js npm test
我们也可以手动指定 reporter: | ||
|
||
```bash | ||
TEST_REPORTER=doc egg-bin test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上,egg-bin 安装在项目里都是找不到的,只能放到 npm scripts 里面才行
1cd9899
to
09f2ec3
Compare
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Checklist
npm test
passesAffected core subsystem(s)
Description of change