Skip to content

组件单元测试指南

Kagol edited this page Dec 15, 2021 · 2 revisions

编写单元测试的步骤

给一个组件编写单元测试分成以下步骤:

  1. 创建单元测试文件 devui/tree/__tests__/tree.spec.ts
  2. 编写测试套 Test Suite describe('tree', () => { ... })
  3. 编写测试用例 it('tree should render correctly', () => { ... })
  4. 编写测试断言 expect(wrapper.classes()).toContain('devui-tree')
  5. 执行测试用例 lerna exec --scope vue-devui yarn test --findRelatedTests devui/button

或者lerna exec --scope vue-devui yarn test --testMatch **/button.spec.ts

参考资料

Clone this wiki locally