- 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.
推薦閱讀
- UML和模式應用(原書第3版)
- 圖解Java數據結構與算法(微課視頻版)
- Unity Virtual Reality Projects
- 區塊鏈:以太坊DApp開發實戰
- The Complete Coding Interview Guide in Java
- 移動界面(Web/App)Photoshop UI設計十全大補
- Mastering JavaScript Design Patterns(Second Edition)
- Spring Boot+MVC實戰指南
- SQL Server 2016 從入門到實戰(視頻教學版)
- 深入實踐DDD:以DSL驅動復雜軟件開發
- WebStorm Essentials
- Java程序設計教程
- After Effects CC案例設計與經典插件(視頻教學版)
- 3D Printing Designs:Octopus Pencil Holder
- INSTANT Lift Web Applications How-to