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

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.
主站蜘蛛池模板: 涟水县| 邵阳县| 额济纳旗| 黎川县| 米林县| 沙湾县| 常德市| 云南省| 高州市| 阿拉尔市| 湖南省| 繁昌县| 竹山县| 太白县| 通渭县| 阳东县| 双城市| 达孜县| 临夏县| 北辰区| 鸡东县| 长治市| 冀州市| 临颍县| 神农架林区| 寻甸| 石柱| 赤峰市| 海盐县| 永寿县| 靖边县| 平和县| 元氏县| 兰西县| 大城县| 安仁县| 石首市| 辽中县| 平利县| 汉川市| 淮阳县|