Master
技术

仅快照测试

NOT ON THE CURRENT EDITION
This blip is not on the current edition of the Radar. If it was on one of the last few editions it is likely that it is still relevant. If the blip is older it might no longer be relevant and our assessment might be different today. Unfortunately, we simply don't have the bandwidth to continuously review blips from previous editions of the RadarUnderstand more
Published: May 19, 2020
May 2020
暂缓?

在遗留系统中工作时,为了保证系统继续运行且不破坏遗留代码功能,快照测试的价值是不可否认的。然而,我们看到了使用 仅快照测试 作为主要测试机制这种常见但有害的做法。快照测试可以验证组件在 DOM 中生成的确切结果,但不能验证组件的行为。 因此,它可能是脆弱且不可靠的,还会催生“仅删除快照后重新生成快照”这样不好的实践。与此相反,您应该通过模拟用户的操作,对组件的逻辑和行为进行测试。 Testing Library 系列中的工具也鼓励这种思维方式。