-
Notifications
You must be signed in to change notification settings - Fork 289
组件单元测试指南
Kagol edited this page Apr 19, 2022
·
2 revisions
给一个组件编写单元测试分成以下步骤:
- 创建单元测试文件
devui/tree/__tests__/tree.spec.ts
- 编写测试套 Test Suite
describe('tree', () => { ... })
- 编写测试用例
it('tree should render correctly', () => { ... })
- 编写测试断言
expect(wrapper.classes()).toContain('devui-tree')
- 执行测试用例
pnpm cli --filter vue-devui -- code-check -t unit-test -c tree,button
orpnpm test --filter vue-devui -- --testMatch **/tree.spec.ts