- Mastering React Test:Driven Development
- Daniel Irvine
- 189字
- 2021-06-24 14:45:04
Streamlining your testing process
Think about the effort you've put into this book so far. What actions have you been doing the most? Most likely, you've been doing these:
- Switching between src/Appointment.js and test/Appointment.test.js
- Running npm test
To solve the first issue, you should use split-screen functionality in your editor. If you aren't already using that, then take this opportunity to learn how to do it. Load your production module on one side and the corresponding unit test file on the other. Here's a picture of my setup:

You can see that I also have a little test window at the bottom for showing test output.
Jest can also watch your files and auto-run tests when they change. To enable this, change the test command in package.json to jest --watchAll. This reruns all of your tests when it detects any changes.
Jest has an option to run only the tests in files that have changed, but you’ll find that since your React app will be composed of many different files, each of which is interconnected, it's better to run everything, as breakages can happen in many modules.
推薦閱讀
- 案例式C語(yǔ)言程序設(shè)計(jì)
- Learn to Create WordPress Themes by Building 5 Projects
- vSphere High Performance Cookbook
- TestNG Beginner's Guide
- 神經(jīng)網(wǎng)絡(luò)編程實(shí)戰(zhàn):Java語(yǔ)言實(shí)現(xiàn)(原書(shū)第2版)
- Banana Pi Cookbook
- Microsoft Dynamics GP 2013 Reporting, Second Edition
- 名師講壇:Java微服務(wù)架構(gòu)實(shí)戰(zhàn)(SpringBoot+SpringCloud+Docker+RabbitMQ)
- 碼上行動(dòng):用ChatGPT學(xué)會(huì)Python編程
- Learning Vaadin 7(Second Edition)
- Building Serverless Architectures
- 微信小程序開(kāi)發(fā)實(shí)戰(zhàn):設(shè)計(jì)·運(yùn)營(yíng)·變現(xiàn)(圖解案例版)
- Learning iOS Security
- Java EE Web應(yīng)用開(kāi)發(fā)基礎(chǔ)
- ASP.NET 4.0 Web程序設(shè)計(jì)