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
- test01 ~ test04: jest, test logical module.
- test05: jest + enzyme, test react component with assert.
- test06: jest, test react component with snapshots.
- 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
- 聊一聊前端自动化测试
- 从工程化角度讨论如何快速构建可靠 React 组件
- How React Components Make UI Testing Easy
- jest API documents
- enzyme API documents
- 使用 Jest + Enzyme 测试 React 应用