jest/no-large-snapshots 风格 ”的永久链接">
用途
使用 Jest 的快照功能时,应该注意创建的快照的大小。一般最佳实践是将快照大小限制在可管理且可审查的范围内。保存的快照的质量完全取决于其审查结果,因此保持它简短、简洁且可读性强对于进行彻底审查非常重要。
示例
javascript
// invalid
exports[`a large snapshot 1`] = `
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10
line 11
line 12
line 13
line 14
line 15
line 16
line 17
line 18
line 19
line 20
line 21
line 22
line 23
line 24
line 25
line 26
line 27
line 28
line 29
line 30
line 31
line 32
line 33
line 34
line 35
line 36
line 37
line 38
line 39
line 40
line 41
line 42
line 43
line 44
line 45
line 46
line 47
line 48
line 49
line 50
line 51
`;
// valid
exports[`a more manageable and readable snapshot 1`] = `
line 1
line 2
line 3
line 4
`;