@@ -15,40 +15,8 @@ test('Shows stats when files are removed', () => {
15
15
require ( './__mocks__/new-stats-assets.json' )
16
16
)
17
17
18
- expect ( printTotalAssetTable ( statsDiff ) ) . toEqual ( `**Total**
19
-
20
- Files count | Type | Total bundle size | % Changed
21
- ----------- | ---- | ----------------- | ---------
22
- 7 -> 2 | bundled<br />gzip | 1.34 MB -> 1.29 MB (-53.65 KB)<br />386.44 KB -> N/A | -3.91%` )
23
- expect ( printAssetTablesByGroup ( statsDiff ) ) . toEqual ( `**Added**
24
-
25
- No assets were added
26
-
27
- **Removed**
28
-
29
- Asset | Type | File Size | % Changed
30
- ----- | ---- | --------- | ---------
31
- 296.chunk.js | bundled<br />gzip | 124.57 KB -> 0 B (-124.57 KB)<br />35.05 KB -> 0 B | -100%
32
- 288.chunk.js | bundled<br />gzip | 57.24 KB -> 0 B (-57.24 KB)<br />16.33 KB -> 0 B | -100%
33
- 920.chunk.js | bundled<br />gzip | 54.98 KB -> 0 B (-54.98 KB)<br />17.08 KB -> 0 B | -100%
34
- 912.chunk.js | bundled<br />gzip | 44.37 KB -> 0 B (-44.37 KB)<br />14.31 KB -> 0 B | -100%
35
- 699.chunk.js | bundled<br />gzip | 26.39 KB -> 0 B (-26.39 KB)<br />6.14 KB -> 0 B | -100%
36
-
37
- **Bigger**
38
-
39
- Asset | Type | File Size | % Changed
40
- ----- | ---- | --------- | ---------
41
- app.bundle.js | bundled<br />gzip | 1.04 MB -> 1.29 MB (+254.35 KB)<br />297.38 KB -> N/A | +23.91%
42
-
43
- **Smaller**
44
-
45
- Asset | Type | File Size | % Changed
46
- ----- | ---- | --------- | ---------
47
- manifest.json | bundled<br />gzip | 551 B -> 91 B (-460 B)<br />151 B -> N/A | -83.48%
48
-
49
- **Unchanged**
50
-
51
- No assets were unchanged` )
18
+ expect ( printTotalAssetTable ( statsDiff ) ) . toMatchSnapshot ( )
19
+ expect ( printAssetTablesByGroup ( statsDiff ) ) . toMatchSnapshot ( )
52
20
} )
53
21
54
22
test ( 'Shows stats when files are added' , ( ) => {
@@ -57,40 +25,8 @@ test('Shows stats when files are added', () => {
57
25
require ( './__mocks__/old-stats-assets.json' )
58
26
)
59
27
60
- expect ( printTotalAssetTable ( statsDiff ) ) . toEqual ( `**Total**
61
-
62
- Files count | Type | Total bundle size | % Changed
63
- ----------- | ---- | ----------------- | ---------
64
- 2 -> 7 | bundled<br />gzip | 1.29 MB -> 1.34 MB (+53.65 KB)<br />N/A -> 386.44 KB | +4.07%` )
65
- expect ( printAssetTablesByGroup ( statsDiff ) ) . toEqual ( `**Added**
66
-
67
- Asset | Type | File Size | % Changed
68
- ----- | ---- | --------- | ---------
69
- 296.chunk.js | bundled<br />gzip | 0 B -> 124.57 KB (+124.57 KB)<br />0 B -> 35.05 KB | -
70
- 288.chunk.js | bundled<br />gzip | 0 B -> 57.24 KB (+57.24 KB)<br />0 B -> 16.33 KB | -
71
- 920.chunk.js | bundled<br />gzip | 0 B -> 54.98 KB (+54.98 KB)<br />0 B -> 17.08 KB | -
72
- 912.chunk.js | bundled<br />gzip | 0 B -> 44.37 KB (+44.37 KB)<br />0 B -> 14.31 KB | -
73
- 699.chunk.js | bundled<br />gzip | 0 B -> 26.39 KB (+26.39 KB)<br />0 B -> 6.14 KB | -
74
-
75
- **Removed**
76
-
77
- No assets were removed
78
-
79
- **Bigger**
80
-
81
- Asset | Type | File Size | % Changed
82
- ----- | ---- | --------- | ---------
83
- manifest.json | bundled<br />gzip | 91 B -> 551 B (+460 B)<br />N/A -> 151 B | +505.49%
84
-
85
- **Smaller**
86
-
87
- Asset | Type | File Size | % Changed
88
- ----- | ---- | --------- | ---------
89
- app.bundle.js | bundled<br />gzip | 1.29 MB -> 1.04 MB (-254.35 KB)<br />N/A -> 297.38 KB | -19.29%
90
-
91
- **Unchanged**
92
-
93
- No assets were unchanged` )
28
+ expect ( printTotalAssetTable ( statsDiff ) ) . toMatchSnapshot ( )
29
+ expect ( printAssetTablesByGroup ( statsDiff ) ) . toMatchSnapshot ( )
94
30
} )
95
31
96
32
test ( 'Shows stats when files are unchanged' , ( ) => {
@@ -99,38 +35,8 @@ test('Shows stats when files are unchanged', () => {
99
35
require ( './__mocks__/old-stats-assets.json' )
100
36
)
101
37
102
- expect ( printTotalAssetTable ( statsDiff ) ) . toEqual ( `**Total**
103
-
104
- Files count | Type | Total bundle size | % Changed
105
- ----------- | ---- | ----------------- | ---------
106
- 7 | bundled<br />gzip | 1.34 MB<br />386.44 KB | 0%` )
107
- expect ( printAssetTablesByGroup ( statsDiff ) ) . toEqual ( `**Added**
108
-
109
- No assets were added
110
-
111
- **Removed**
112
-
113
- No assets were removed
114
-
115
- **Bigger**
116
-
117
- No assets were bigger
118
-
119
- **Smaller**
120
-
121
- No assets were smaller
122
-
123
- **Unchanged**
124
-
125
- Asset | Type | File Size | % Changed
126
- ----- | ---- | --------- | ---------
127
- app.bundle.js | bundled<br />gzip | 1.04 MB<br />297.38 KB | 0%
128
- 296.chunk.js | bundled<br />gzip | 124.57 KB<br />35.05 KB | 0%
129
- 288.chunk.js | bundled<br />gzip | 57.24 KB<br />16.33 KB | 0%
130
- 920.chunk.js | bundled<br />gzip | 54.98 KB<br />17.08 KB | 0%
131
- 912.chunk.js | bundled<br />gzip | 44.37 KB<br />14.31 KB | 0%
132
- 699.chunk.js | bundled<br />gzip | 26.39 KB<br />6.14 KB | 0%
133
- manifest.json | bundled<br />gzip | 551 B<br />151 B | 0%` )
38
+ expect ( printTotalAssetTable ( statsDiff ) ) . toMatchSnapshot ( )
39
+ expect ( printAssetTablesByGroup ( statsDiff ) ) . toMatchSnapshot ( )
134
40
} )
135
41
136
42
test ( 'computes the correct module diff information' , ( ) => {
@@ -178,42 +84,7 @@ test('displays module information when files are added/removed/changed', () => {
178
84
require ( './__mocks__/new-stats-with-chunks.json' )
179
85
)
180
86
181
- console . log ( printChunkModulesTable ( statsDiff ) )
182
-
183
- expect ( printChunkModulesTable ( statsDiff ) ) . toEqual ( `
184
- **Changeset**
185
-
186
- File | Δ
187
- ---- | -
188
- \`src/client/this/file/has/a/long/name/so-that-it-will-hopefully-wrap.tsx\` | 🆕 +2.72 KB
189
- \`src/client/this-file-was-added.ts\` | 🆕 +1.46 KB
190
- \`src/client/this-is-another-file-with-a-long-name-to-test-the-table-sizing.tsx\` | 🆕 +1.04 KB
191
- \`src/client/helpers/this-file-is-much-larger.ts\` | 📈 +11.66 KB (+865.77%)
192
- \`src/client/this-file-grew-larger.tsx\` | 📈 +200 B (+35.59%)
193
- \`src/client/helpers/this-file-grew-smaller.ts\` | 📉 -200 B (-7.94%)
194
- \`src/client/this-file-is-much-smaller.tsx\` | 📉 -11.66 KB (-99.92%)
195
- \`src/client/routes.tsx\` | 🔥 -2.72 KB (-100%)
196
- \`src/client/this-file-will-be-deleted.ts\` | 🔥 -1.46 KB (-100%)
197
- \`src/client/render-memex.tsx\` | 🔥 -1.04 KB (-100%)
198
-
199
- <details>
200
- <summary>View detailed changes</summary>
201
-
202
- File | Old | New | Δ
203
- ---- | --- | --- | -
204
- \`src/client/this/file/has/a/long/name/so-that-it-will-hopefully-wrap.tsx\` | 0 B | 2.72 KB | 🆕 +2.72 KB
205
- \`src/client/this-file-was-added.ts\` | 0 B | 1.46 KB | 🆕 +1.46 KB
206
- \`src/client/this-is-another-file-with-a-long-name-to-test-the-table-sizing.tsx\` | 0 B | 1.04 KB | 🆕 +1.04 KB
207
- \`src/client/helpers/this-file-is-much-larger.ts\` | 1.35 KB | 13.01 KB | 📈 +11.66 KB (+865.77%)
208
- \`src/client/this-file-grew-larger.tsx\` | 562 B | 762 B | 📈 +200 B (+35.59%)
209
- \`src/client/helpers/this-file-grew-smaller.ts\` | 2.46 KB | 2.26 KB | 📉 -200 B (-7.94%)
210
- \`src/client/this-file-is-much-smaller.tsx\` | 11.67 KB | 10 B | 📉 -11.66 KB (-99.92%)
211
- \`src/client/routes.tsx\` | 2.72 KB | 0 B | 🔥 -2.72 KB (-100%)
212
- \`src/client/this-file-will-be-deleted.ts\` | 1.46 KB | 0 B | 🔥 -1.46 KB (-100%)
213
- \`src/client/render-memex.tsx\` | 1.04 KB | 0 B | 🔥 -1.04 KB (-100%)
214
-
215
- </details>
216
- ` )
87
+ expect ( printChunkModulesTable ( statsDiff ) ) . toMatchSnapshot ( )
217
88
} )
218
89
219
90
test ( 'displays no module information when unchanged' , ( ) => {
@@ -222,9 +93,7 @@ test('displays no module information when unchanged', () => {
222
93
require ( './__mocks__/old-stats-with-chunks.json' )
223
94
)
224
95
225
- expect ( printChunkModulesTable ( statsDiff ) ) . toEqual (
226
- `\n**Changeset**\n\nNo files were changed`
227
- )
96
+ expect ( printChunkModulesTable ( statsDiff ) ) . toMatchSnapshot ( )
228
97
} )
229
98
230
99
test ( 'does not display module information when it does not exist' , ( ) => {
@@ -233,5 +102,5 @@ test('does not display module information when it does not exist', () => {
233
102
require ( './__mocks__/old-stats-assets.json' )
234
103
)
235
104
236
- expect ( printChunkModulesTable ( statsDiff ) ) . toEqual ( '' )
105
+ expect ( printChunkModulesTable ( statsDiff ) ) . toMatchSnapshot ( )
237
106
} )
0 commit comments