官术网_书友最值得收藏!

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.
主站蜘蛛池模板: 瑞安市| 汾阳市| 防城港市| 黔江区| 昌吉市| 安阳县| 曲松县| 任丘市| 将乐县| 壤塘县| 广汉市| 玉田县| 马公市| 红桥区| 房山区| 包头市| 辽阳市| 绥滨县| 灌云县| 淮北市| 新干县| 灌云县| 集安市| 南通市| 湄潭县| 大埔区| 遵化市| 噶尔县| 安仁县| 太和县| 酉阳| 丰都县| 德化县| 台中市| 高青县| 沧源| 隆安县| 长丰县| 施甸县| 金门县| 公主岭市|