2022-02-16 11:20:17 +08:00

40 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 如何共建
1. 拉取最新代码,切换到 develop 分支,基于 develop 分支切出一个 feature 或 hotfix 分支
2. 安装依赖(`npm`),然后先跑一遍 `npm test` 看看是否所有用例都能通过 (如果网络条件不太好,建议使用 [cnpm - 淘宝提供的中国 NPM 镜像](https://npmmirror.com/))
3. 在 tests 目录下编写您的需求/问题的测试用例
4. 修改 src 下的一些代码,然后运行 `npm test``npm start` 启动 jest 进行调测
5. 确保所有的测试用例都能通过时,提 MR 给 @牧毅 -- MR 将在 1 个工作日内给您回复意见。
当然,欢迎提前私聊沟通 @牧毅,或加入 低代码渲染/出码服务金牌用户群 讨论沟通。
# FAQ
## 如何查看单测覆盖率?
执行 `npm test:cov` 命令,这样会自动生成单测覆盖率的报告到 `coverage` 目录下。
## 如何只执行一个测试用例?
```sh
npm test -t 'demo2-utils-name-alias'
```
## 更新特定测试用例的 expected:
```sh
npm test:update-snapshots -t 'demo2-utils-name-alias'
```
## 如何只执行某个测试用例文件?
执行 `npx jest 测试用例的文件路径` 即可,如:
```sh
npx jest tests/plugins/common/requireUtils.test.ts
```
## 如何调试某个测试用例?
建议需要打断点的地方通过 VSCode 打上断点,然后打开 VSCode 的 JavaScript Debug Terminal在其中执行 `npx jest tests/path/to/your/test/file.ts``npx jest -t your-test-case-title` 来执行你的测试用例 -- 这样执行到打了断点的语句时会自动断住,以便调试。