react-testing-demo

Ensure code quality of React components with jest, enzyme, jsdom, eslint.

Stars
5
Committers
1

react-testing-demo

Some simple code / demo about how to to test in React with jest + enzyme + eslint.

1. About test

  • E2E test: 10%
  • Integration test: 20%
  • Unit test: 70%

2. Introduce

  1. test01 ~ test04: jest, test logical module.
  2. test05: jest + enzyme, test react component with assert.
  3. test06: jest, test react component with snapshots.
  4. test07: jest + jsdom, test react component, and mock the document function in setupFiles.

3. Run

git clone [email protected]:hustcc/react-testing-demo.git

cd react-testing-demo

npm i 

npm test

4. Read

  1. 聊一聊前端自动化测试
  2. 从工程化角度讨论如何快速构建可靠 React 组件
  3. How React Components Make UI Testing Easy
  4. jest API documents
  5. enzyme API documents
  6. 使用 Jest + Enzyme 测试 React 应用