Jest Snapshot testing vs unit testing?

后端 未结 3 645
被撕碎了的回忆
被撕碎了的回忆 2021-02-12 15:59

It\'s fairly easy to implement snapshot testing in jest but it\'s something I am not really comfortable with because it feels like I am not actually testing anything. In unit te

3条回答
  •  别跟我提以往
    2021-02-12 16:42

    You should write both snapshot and unit tests. Snapshot tests will check for changes when rendering, like if className, inline styles, some conditional rendering or loops are not working as they worked before. You should still write unit tests for any functionality that can't be checked with simple rendering (if onClick is called when clicked and so on).

提交回复
热议问题