Skip to content

Commit 3ac4188

Browse files
authored
Merge pull request #162 from github/changeset-in-details-with-details
Changeset in details with details
2 parents 34b5e51 + 58fc2b0 commit 3ac4188

File tree

7 files changed

+264
-246
lines changed

7 files changed

+264
-246
lines changed
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Shows stats when files are added 1`] = `
4+
"**Total**
5+
6+
Files count | Type | Total bundle size | % Changed
7+
----------- | ---- | ----------------- | ---------
8+
2 -> 7 | bundled<br />gzip | 1.29 MB -> 1.34 MB (+53.65 KB)<br />N/A -> 386.44 KB | +4.07%"
9+
`;
10+
11+
exports[`Shows stats when files are added 2`] = `
12+
"**Added**
13+
14+
Asset | Type | File Size | % Changed
15+
----- | ---- | --------- | ---------
16+
296.chunk.js | bundled<br />gzip | 0 B -> 124.57 KB (+124.57 KB)<br />0 B -> 35.05 KB | -
17+
288.chunk.js | bundled<br />gzip | 0 B -> 57.24 KB (+57.24 KB)<br />0 B -> 16.33 KB | -
18+
920.chunk.js | bundled<br />gzip | 0 B -> 54.98 KB (+54.98 KB)<br />0 B -> 17.08 KB | -
19+
912.chunk.js | bundled<br />gzip | 0 B -> 44.37 KB (+44.37 KB)<br />0 B -> 14.31 KB | -
20+
699.chunk.js | bundled<br />gzip | 0 B -> 26.39 KB (+26.39 KB)<br />0 B -> 6.14 KB | -
21+
22+
**Removed**
23+
24+
No assets were removed
25+
26+
**Bigger**
27+
28+
Asset | Type | File Size | % Changed
29+
----- | ---- | --------- | ---------
30+
manifest.json | bundled<br />gzip | 91 B -> 551 B (+460 B)<br />N/A -> 151 B | +505.49%
31+
32+
**Smaller**
33+
34+
Asset | Type | File Size | % Changed
35+
----- | ---- | --------- | ---------
36+
app.bundle.js | bundled<br />gzip | 1.29 MB -> 1.04 MB (-254.35 KB)<br />N/A -> 297.38 KB | -19.29%
37+
38+
**Unchanged**
39+
40+
No assets were unchanged"
41+
`;
42+
43+
exports[`Shows stats when files are removed 1`] = `
44+
"**Total**
45+
46+
Files count | Type | Total bundle size | % Changed
47+
----------- | ---- | ----------------- | ---------
48+
7 -> 2 | bundled<br />gzip | 1.34 MB -> 1.29 MB (-53.65 KB)<br />386.44 KB -> N/A | -3.91%"
49+
`;
50+
51+
exports[`Shows stats when files are removed 2`] = `
52+
"**Added**
53+
54+
No assets were added
55+
56+
**Removed**
57+
58+
Asset | Type | File Size | % Changed
59+
----- | ---- | --------- | ---------
60+
296.chunk.js | bundled<br />gzip | 124.57 KB -> 0 B (-124.57 KB)<br />35.05 KB -> 0 B | -100%
61+
288.chunk.js | bundled<br />gzip | 57.24 KB -> 0 B (-57.24 KB)<br />16.33 KB -> 0 B | -100%
62+
920.chunk.js | bundled<br />gzip | 54.98 KB -> 0 B (-54.98 KB)<br />17.08 KB -> 0 B | -100%
63+
912.chunk.js | bundled<br />gzip | 44.37 KB -> 0 B (-44.37 KB)<br />14.31 KB -> 0 B | -100%
64+
699.chunk.js | bundled<br />gzip | 26.39 KB -> 0 B (-26.39 KB)<br />6.14 KB -> 0 B | -100%
65+
66+
**Bigger**
67+
68+
Asset | Type | File Size | % Changed
69+
----- | ---- | --------- | ---------
70+
app.bundle.js | bundled<br />gzip | 1.04 MB -> 1.29 MB (+254.35 KB)<br />297.38 KB -> N/A | +23.91%
71+
72+
**Smaller**
73+
74+
Asset | Type | File Size | % Changed
75+
----- | ---- | --------- | ---------
76+
manifest.json | bundled<br />gzip | 551 B -> 91 B (-460 B)<br />151 B -> N/A | -83.48%
77+
78+
**Unchanged**
79+
80+
No assets were unchanged"
81+
`;
82+
83+
exports[`Shows stats when files are unchanged 1`] = `
84+
"**Total**
85+
86+
Files count | Type | Total bundle size | % Changed
87+
----------- | ---- | ----------------- | ---------
88+
7 | bundled<br />gzip | 1.34 MB<br />386.44 KB | 0%"
89+
`;
90+
91+
exports[`Shows stats when files are unchanged 2`] = `
92+
"**Added**
93+
94+
No assets were added
95+
96+
**Removed**
97+
98+
No assets were removed
99+
100+
**Bigger**
101+
102+
No assets were bigger
103+
104+
**Smaller**
105+
106+
No assets were smaller
107+
108+
**Unchanged**
109+
110+
Asset | Type | File Size | % Changed
111+
----- | ---- | --------- | ---------
112+
app.bundle.js | bundled<br />gzip | 1.04 MB<br />297.38 KB | 0%
113+
296.chunk.js | bundled<br />gzip | 124.57 KB<br />35.05 KB | 0%
114+
288.chunk.js | bundled<br />gzip | 57.24 KB<br />16.33 KB | 0%
115+
920.chunk.js | bundled<br />gzip | 54.98 KB<br />17.08 KB | 0%
116+
912.chunk.js | bundled<br />gzip | 44.37 KB<br />14.31 KB | 0%
117+
699.chunk.js | bundled<br />gzip | 26.39 KB<br />6.14 KB | 0%
118+
manifest.json | bundled<br />gzip | 551 B<br />151 B | 0%"
119+
`;
120+
121+
exports[`displays module information when files are added/removed/changed 1`] = `
122+
"
123+
<details>
124+
<summary>**Changeset**</summary>
125+
126+
File | Δ
127+
---- | -
128+
\`src/client/this/file/has/a/long/name/so-that-it-will-hopefully-wrap.tsx\` | 🆕 +2.72 KB
129+
\`src/client/this-file-was-added.ts\` | 🆕 +1.46 KB
130+
\`src/client/this-is-another-file-with-a-long-name-to-test-the-table-sizing.tsx\` | 🆕 +1.04 KB
131+
\`src/client/helpers/this-file-is-much-larger.ts\` | 📈 +11.66 KB (+865.77%)
132+
\`src/client/this-file-grew-larger.tsx\` | 📈 +200 B (+35.59%)
133+
\`src/client/helpers/this-file-grew-smaller.ts\` | 📉 -200 B (-7.94%)
134+
\`src/client/this-file-is-much-smaller.tsx\` | 📉 -11.66 KB (-99.92%)
135+
\`src/client/routes.tsx\` | 🔥 -2.72 KB (-100%)
136+
\`src/client/this-file-will-be-deleted.ts\` | 🔥 -1.46 KB (-100%)
137+
\`src/client/render-memex.tsx\` | 🔥 -1.04 KB (-100%)
138+
139+
<details>
140+
<summary>View individual file sizes</summary>
141+
142+
File | Old | New | Δ
143+
---- | --- | --- | -
144+
\`src/client/this/file/has/a/long/name/so-that-it-will-hopefully-wrap.tsx\` | 0 B | 2.72 KB | 🆕 +2.72 KB
145+
\`src/client/this-file-was-added.ts\` | 0 B | 1.46 KB | 🆕 +1.46 KB
146+
\`src/client/this-is-another-file-with-a-long-name-to-test-the-table-sizing.tsx\` | 0 B | 1.04 KB | 🆕 +1.04 KB
147+
\`src/client/helpers/this-file-is-much-larger.ts\` | 1.35 KB | 13.01 KB | 📈 +11.66 KB (+865.77%)
148+
\`src/client/this-file-grew-larger.tsx\` | 562 B | 762 B | 📈 +200 B (+35.59%)
149+
\`src/client/helpers/this-file-grew-smaller.ts\` | 2.46 KB | 2.26 KB | 📉 -200 B (-7.94%)
150+
\`src/client/this-file-is-much-smaller.tsx\` | 11.67 KB | 10 B | 📉 -11.66 KB (-99.92%)
151+
\`src/client/routes.tsx\` | 2.72 KB | 0 B | 🔥 -2.72 KB (-100%)
152+
\`src/client/this-file-will-be-deleted.ts\` | 1.46 KB | 0 B | 🔥 -1.46 KB (-100%)
153+
\`src/client/render-memex.tsx\` | 1.04 KB | 0 B | 🔥 -1.04 KB (-100%)
154+
155+
</details>
156+
157+
</details>
158+
"
159+
`;
160+
161+
exports[`displays no module information when unchanged 1`] = `
162+
"
163+
**Changeset**
164+
165+
No files were changed"
166+
`;
167+
168+
exports[`does not display module information when it does not exist 1`] = `""`;

__tests__/main.test.ts

Lines changed: 9 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,8 @@ test('Shows stats when files are removed', () => {
1515
require('./__mocks__/new-stats-assets.json')
1616
)
1717

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()
5220
})
5321

5422
test('Shows stats when files are added', () => {
@@ -57,40 +25,8 @@ test('Shows stats when files are added', () => {
5725
require('./__mocks__/old-stats-assets.json')
5826
)
5927

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()
9430
})
9531

9632
test('Shows stats when files are unchanged', () => {
@@ -99,38 +35,8 @@ test('Shows stats when files are unchanged', () => {
9935
require('./__mocks__/old-stats-assets.json')
10036
)
10137

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()
13440
})
13541

13642
test('computes the correct module diff information', () => {
@@ -178,42 +84,7 @@ test('displays module information when files are added/removed/changed', () => {
17884
require('./__mocks__/new-stats-with-chunks.json')
17985
)
18086

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()
21788
})
21889

21990
test('displays no module information when unchanged', () => {
@@ -222,9 +93,7 @@ test('displays no module information when unchanged', () => {
22293
require('./__mocks__/old-stats-with-chunks.json')
22394
)
22495

225-
expect(printChunkModulesTable(statsDiff)).toEqual(
226-
`\n**Changeset**\n\nNo files were changed`
227-
)
96+
expect(printChunkModulesTable(statsDiff)).toMatchSnapshot()
22897
})
22998

23099
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', () => {
233102
require('./__mocks__/old-stats-assets.json')
234103
)
235104

236-
expect(printChunkModulesTable(statsDiff)).toEqual('')
105+
expect(printChunkModulesTable(statsDiff)).toMatchSnapshot()
237106
})

dist/index.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)