-
Notifications
You must be signed in to change notification settings - Fork 288
组件单元测试指南
Kagol edited this page Dec 15, 2021
·
2 revisions
给一个组件编写单元测试分成以下步骤:
- 创建单元测试文件
devui/tree/__tests__/tree.spec.ts
- 编写测试套 Test Suite
describe('tree', () => { ... })
- 编写测试用例
it('tree should render correctly', () => { ... })
- 编写测试断言
expect(wrapper.classes()).toContain('devui-tree')
- 执行测试用例
lerna exec --scope vue-devui yarn test --findRelatedTests devui/button
或者lerna exec --scope vue-devui yarn test --testMatch **/button.spec.ts