Skip to content

Commit d6d6622

Browse files
test(e2e): stop pinning asset gzipSize in rollup/vite/webpack snapshots
- Add bundleStatsAssetsHint() using expect.arrayContaining + objectContaining({ gzipSize: expect.any(Number), ... }) so Bun snapshots store ExpectArrayContaining instead of OS/Node-specific gzip lengths - Regenerate rollup, vite, and webpack snapshot files - Run e2e with --timeout 120000 and --max-concurrency=1 to avoid flaky 5s default timeouts and parallel races - Gitignore Vite timestamp artifacts under fixtures/vite Made-with: Cursor
1 parent 78a02f9 commit d6d6622

File tree

9 files changed

+82
-434
lines changed

9 files changed

+82
-434
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { expect } from "bun:test";
2+
3+
/**
4+
* Use inside `toMatchSnapshot({ ... })` for bundle stats payloads that include `assets[]`.
5+
* Compressed size (`gzipSize`) varies by OS and Node.js zlib, so snapshots must not pin it.
6+
*/
7+
export function bundleStatsAssetsHint() {
8+
return expect.arrayContaining([
9+
expect.objectContaining({
10+
gzipSize: expect.any(Number),
11+
name: expect.any(String),
12+
normalized: expect.any(String),
13+
size: expect.any(Number),
14+
}),
15+
]);
16+
}

integration-tests/fixtures/generate-bundle-stats/rollup/__snapshots__/rollup-plugin.test.ts.snap

Lines changed: 20 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22

33
exports[`Generating rollup stats 3 {"format":"amd","expected":"amd"} matches the snapshot 1`] = `
44
{
5-
"assets": [
6-
{
7-
"gzipSize": 98808,
8-
"name": "main-1cbfd464.js",
9-
"normalized": "main-*.js",
10-
"size": 577073,
11-
},
12-
],
5+
"assets": ExpectArrayContaining {},
136
"builtAt": Any<Number>,
147
"bundleName": StringContaining "test-rollup-v3-amd",
158
"bundler": {
@@ -80,14 +73,7 @@ exports[`Generating rollup stats 3 {"format":"amd","expected":"amd"} matches the
8073
8174
exports[`Generating rollup stats 3 {"format":"cjs","expected":"cjs"} matches the snapshot 1`] = `
8275
{
83-
"assets": [
84-
{
85-
"gzipSize": 98252,
86-
"name": "main-420d8aeb.js",
87-
"normalized": "main-*.js",
88-
"size": 560888,
89-
},
90-
],
76+
"assets": ExpectArrayContaining {},
9177
"builtAt": Any<Number>,
9278
"bundleName": StringContaining "test-rollup-v3-cjs",
9379
"bundler": {
@@ -158,14 +144,7 @@ exports[`Generating rollup stats 3 {"format":"cjs","expected":"cjs"} matches the
158144
159145
exports[`Generating rollup stats 3 {"format":"es","expected":"esm"} matches the snapshot 1`] = `
160146
{
161-
"assets": [
162-
{
163-
"gzipSize": 98243,
164-
"name": "main-6ff1e9ca.js",
165-
"normalized": "main-*.js",
166-
"size": 560873,
167-
},
168-
],
147+
"assets": ExpectArrayContaining {},
169148
"builtAt": Any<Number>,
170149
"bundleName": StringContaining "test-rollup-v3-esm",
171150
"bundler": {
@@ -236,14 +215,7 @@ exports[`Generating rollup stats 3 {"format":"es","expected":"esm"} matches the
236215
237216
exports[`Generating rollup stats 3 {"format":"esm","expected":"esm"} matches the snapshot 1`] = `
238217
{
239-
"assets": [
240-
{
241-
"gzipSize": 98243,
242-
"name": "main-6ff1e9ca.js",
243-
"normalized": "main-*.js",
244-
"size": 560873,
245-
},
246-
],
218+
"assets": ExpectArrayContaining {},
247219
"builtAt": Any<Number>,
248220
"bundleName": StringContaining "test-rollup-v3-esm",
249221
"bundler": {
@@ -314,14 +286,7 @@ exports[`Generating rollup stats 3 {"format":"esm","expected":"esm"} matches the
314286
315287
exports[`Generating rollup stats 3 {"format":"module","expected":"esm"} matches the snapshot 1`] = `
316288
{
317-
"assets": [
318-
{
319-
"gzipSize": 98243,
320-
"name": "main-6ff1e9ca.js",
321-
"normalized": "main-*.js",
322-
"size": 560873,
323-
},
324-
],
289+
"assets": ExpectArrayContaining {},
325290
"builtAt": Any<Number>,
326291
"bundleName": StringContaining "test-rollup-v3-esm",
327292
"bundler": {
@@ -392,14 +357,7 @@ exports[`Generating rollup stats 3 {"format":"module","expected":"esm"} matches
392357
393358
exports[`Generating rollup stats 3 {"format":"iife","expected":"iife"} matches the snapshot 1`] = `
394359
{
395-
"assets": [
396-
{
397-
"gzipSize": 98804,
398-
"name": "main-cc182ba1.js",
399-
"normalized": "main-*.js",
400-
"size": 577068,
401-
},
402-
],
360+
"assets": ExpectArrayContaining {},
403361
"builtAt": Any<Number>,
404362
"bundleName": StringContaining "test-rollup-v3-iife",
405363
"bundler": {
@@ -470,14 +428,7 @@ exports[`Generating rollup stats 3 {"format":"iife","expected":"iife"} matches t
470428
471429
exports[`Generating rollup stats 3 {"format":"umd","expected":"umd"} matches the snapshot 1`] = `
472430
{
473-
"assets": [
474-
{
475-
"gzipSize": 98845,
476-
"name": "main-cdb2522f.js",
477-
"normalized": "main-*.js",
478-
"size": 577167,
479-
},
480-
],
431+
"assets": ExpectArrayContaining {},
481432
"builtAt": Any<Number>,
482433
"bundleName": StringContaining "test-rollup-v3-umd",
483434
"bundler": {
@@ -548,14 +499,7 @@ exports[`Generating rollup stats 3 {"format":"umd","expected":"umd"} matches the
548499
549500
exports[`Generating rollup stats 3 {"format":"system","expected":"system"} matches the snapshot 1`] = `
550501
{
551-
"assets": [
552-
{
553-
"gzipSize": 99908,
554-
"name": "main-b7135d24.js",
555-
"normalized": "main-*.js",
556-
"size": 609446,
557-
},
558-
],
502+
"assets": ExpectArrayContaining {},
559503
"builtAt": Any<Number>,
560504
"bundleName": StringContaining "test-rollup-v3-system",
561505
"bundler": {
@@ -626,14 +570,7 @@ exports[`Generating rollup stats 3 {"format":"system","expected":"system"} match
626570
627571
exports[`Generating rollup stats 3 {"format":"systemjs","expected":"system"} matches the snapshot 1`] = `
628572
{
629-
"assets": [
630-
{
631-
"gzipSize": 99908,
632-
"name": "main-b7135d24.js",
633-
"normalized": "main-*.js",
634-
"size": 609446,
635-
},
636-
],
573+
"assets": ExpectArrayContaining {},
637574
"builtAt": Any<Number>,
638575
"bundleName": StringContaining "test-rollup-v3-system",
639576
"bundler": {
@@ -704,14 +641,7 @@ exports[`Generating rollup stats 3 {"format":"systemjs","expected":"system"} mat
704641
705642
exports[`Generating rollup stats 3 source maps are enabled does not include any source maps 1`] = `
706643
{
707-
"assets": [
708-
{
709-
"gzipSize": 98275,
710-
"name": "main-6ff1e9ca.js",
711-
"normalized": "main-*.js",
712-
"size": 560915,
713-
},
714-
],
644+
"assets": ExpectArrayContaining {},
715645
"builtAt": Any<Number>,
716646
"bundleName": StringNotContaining ".map",
717647
"bundler": {
@@ -782,14 +712,7 @@ exports[`Generating rollup stats 3 source maps are enabled does not include any
782712
783713
exports[`Generating rollup stats 4 {"format":"amd","expected":"amd"} matches the snapshot 1`] = `
784714
{
785-
"assets": [
786-
{
787-
"gzipSize": 98808,
788-
"name": "main-Bz9ahex4.js",
789-
"normalized": "main-*.js",
790-
"size": 577073,
791-
},
792-
],
715+
"assets": ExpectArrayContaining {},
793716
"builtAt": Any<Number>,
794717
"bundleName": StringContaining "test-rollup-v4-amd",
795718
"bundler": {
@@ -860,14 +783,7 @@ exports[`Generating rollup stats 4 {"format":"amd","expected":"amd"} matches the
860783
861784
exports[`Generating rollup stats 4 {"format":"cjs","expected":"cjs"} matches the snapshot 1`] = `
862785
{
863-
"assets": [
864-
{
865-
"gzipSize": 98252,
866-
"name": "main-xb59kfqA.js",
867-
"normalized": "main-*.js",
868-
"size": 560888,
869-
},
870-
],
786+
"assets": ExpectArrayContaining {},
871787
"builtAt": Any<Number>,
872788
"bundleName": StringContaining "test-rollup-v4-cjs",
873789
"bundler": {
@@ -938,14 +854,7 @@ exports[`Generating rollup stats 4 {"format":"cjs","expected":"cjs"} matches the
938854
939855
exports[`Generating rollup stats 4 {"format":"es","expected":"esm"} matches the snapshot 1`] = `
940856
{
941-
"assets": [
942-
{
943-
"gzipSize": 98243,
944-
"name": "main-DTMU6eC0.js",
945-
"normalized": "main-*.js",
946-
"size": 560873,
947-
},
948-
],
857+
"assets": ExpectArrayContaining {},
949858
"builtAt": Any<Number>,
950859
"bundleName": StringContaining "test-rollup-v4-esm",
951860
"bundler": {
@@ -1016,14 +925,7 @@ exports[`Generating rollup stats 4 {"format":"es","expected":"esm"} matches the
1016925
1017926
exports[`Generating rollup stats 4 {"format":"esm","expected":"esm"} matches the snapshot 1`] = `
1018927
{
1019-
"assets": [
1020-
{
1021-
"gzipSize": 98243,
1022-
"name": "main-DTMU6eC0.js",
1023-
"normalized": "main-*.js",
1024-
"size": 560873,
1025-
},
1026-
],
928+
"assets": ExpectArrayContaining {},
1027929
"builtAt": Any<Number>,
1028930
"bundleName": StringContaining "test-rollup-v4-esm",
1029931
"bundler": {
@@ -1094,14 +996,7 @@ exports[`Generating rollup stats 4 {"format":"esm","expected":"esm"} matches the
1094996
1095997
exports[`Generating rollup stats 4 {"format":"module","expected":"esm"} matches the snapshot 1`] = `
1096998
{
1097-
"assets": [
1098-
{
1099-
"gzipSize": 98243,
1100-
"name": "main-DTMU6eC0.js",
1101-
"normalized": "main-*.js",
1102-
"size": 560873,
1103-
},
1104-
],
999+
"assets": ExpectArrayContaining {},
11051000
"builtAt": Any<Number>,
11061001
"bundleName": StringContaining "test-rollup-v4-esm",
11071002
"bundler": {
@@ -1172,14 +1067,7 @@ exports[`Generating rollup stats 4 {"format":"module","expected":"esm"} matches
11721067
11731068
exports[`Generating rollup stats 4 {"format":"iife","expected":"iife"} matches the snapshot 1`] = `
11741069
{
1175-
"assets": [
1176-
{
1177-
"gzipSize": 98804,
1178-
"name": "main-B7VbaLUG.js",
1179-
"normalized": "main-*.js",
1180-
"size": 577068,
1181-
},
1182-
],
1070+
"assets": ExpectArrayContaining {},
11831071
"builtAt": Any<Number>,
11841072
"bundleName": StringContaining "test-rollup-v4-iife",
11851073
"bundler": {
@@ -1250,14 +1138,7 @@ exports[`Generating rollup stats 4 {"format":"iife","expected":"iife"} matches t
12501138
12511139
exports[`Generating rollup stats 4 {"format":"umd","expected":"umd"} matches the snapshot 1`] = `
12521140
{
1253-
"assets": [
1254-
{
1255-
"gzipSize": 98845,
1256-
"name": "main-DXhL8JQx.js",
1257-
"normalized": "main-*.js",
1258-
"size": 577167,
1259-
},
1260-
],
1141+
"assets": ExpectArrayContaining {},
12611142
"builtAt": Any<Number>,
12621143
"bundleName": StringContaining "test-rollup-v4-umd",
12631144
"bundler": {
@@ -1328,14 +1209,7 @@ exports[`Generating rollup stats 4 {"format":"umd","expected":"umd"} matches the
13281209
13291210
exports[`Generating rollup stats 4 {"format":"system","expected":"system"} matches the snapshot 1`] = `
13301211
{
1331-
"assets": [
1332-
{
1333-
"gzipSize": 99908,
1334-
"name": "main-DwblAVj_.js",
1335-
"normalized": "main-*.js",
1336-
"size": 609446,
1337-
},
1338-
],
1212+
"assets": ExpectArrayContaining {},
13391213
"builtAt": Any<Number>,
13401214
"bundleName": StringContaining "test-rollup-v4-system",
13411215
"bundler": {
@@ -1406,14 +1280,7 @@ exports[`Generating rollup stats 4 {"format":"system","expected":"system"} match
14061280
14071281
exports[`Generating rollup stats 4 {"format":"systemjs","expected":"system"} matches the snapshot 1`] = `
14081282
{
1409-
"assets": [
1410-
{
1411-
"gzipSize": 99908,
1412-
"name": "main-DwblAVj_.js",
1413-
"normalized": "main-*.js",
1414-
"size": 609446,
1415-
},
1416-
],
1283+
"assets": ExpectArrayContaining {},
14171284
"builtAt": Any<Number>,
14181285
"bundleName": StringContaining "test-rollup-v4-system",
14191286
"bundler": {
@@ -1484,14 +1351,7 @@ exports[`Generating rollup stats 4 {"format":"systemjs","expected":"system"} mat
14841351
14851352
exports[`Generating rollup stats 4 source maps are enabled does not include any source maps 1`] = `
14861353
{
1487-
"assets": [
1488-
{
1489-
"gzipSize": 98275,
1490-
"name": "main-DTMU6eC0.js",
1491-
"normalized": "main-*.js",
1492-
"size": 560915,
1493-
},
1494-
],
1354+
"assets": ExpectArrayContaining {},
14951355
"builtAt": Any<Number>,
14961356
"bundleName": StringNotContaining ".map",
14971357
"bundler": {

integration-tests/fixtures/generate-bundle-stats/rollup/rollup-plugin.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { $ } from "bun";
33
import { describe, it, expect, afterEach, beforeEach } from "bun:test";
44
import { GenerateConfig } from "../../../scripts/gen-config";
5+
import { bundleStatsAssetsHint } from "../bundle-stats-snapshot-hints";
56

67
const rollupPath = (version: number) =>
78
`node_modules/rollupV${version}/dist/bin/rollup`;
@@ -70,6 +71,7 @@ describe("Generating rollup stats", () => {
7071
bundleName: expect.stringContaining(
7172
`test-rollup-v${version}-${expected}`,
7273
),
74+
assets: bundleStatsAssetsHint(),
7375
plugin: {
7476
name: expect.stringMatching("@codecov/rollup-plugin"),
7577
},
@@ -119,6 +121,7 @@ describe("Generating rollup stats", () => {
119121
duration: expect.any(Number),
120122
outputPath: expect.stringContaining(`/distV${version}`),
121123
bundleName: expect.not.stringContaining(".map"),
124+
assets: bundleStatsAssetsHint(),
122125
plugin: {
123126
name: expect.stringMatching("@codecov/rollup-plugin"),
124127
},
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vite-*.config.ts.timestamp-*

0 commit comments

Comments
 (0)