Skip to content

Commit 8f1d35c

Browse files
committed
git commit --amend --author="Srushti <[email protected]>"Add real-world test scenarios for incomplete stats
1 parent 2b334dd commit 8f1d35c

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

test/real-world-stats.test.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const {expect} = require('chai');
2+
const analyzer = require('../lib/analyzer');
3+
4+
describe('Real-world incomplete stats scenarios', function() {
5+
it('should handle stats from minimal webpack config', function() {
6+
const realWorldStats = {
7+
version: "5.0.0",
8+
hash: "abc123def456",
9+
publicPath: "/dist/",
10+
outputPath: "/project/dist",
11+
chunks: [
12+
{
13+
id: 0,
14+
names: ["main"],
15+
files: ["main.js"],
16+
hash: "abc123",
17+
size: 1024
18+
}
19+
],
20+
// Real-world scenario: assets array missing (common in minimal configs)
21+
// Real-world scenario: modules array missing (some webpack versions)
22+
errors: [],
23+
warnings: [],
24+
entrypoints: {
25+
main: {
26+
chunks: [0],
27+
assets: ["main.js"]
28+
}
29+
}
30+
};
31+
32+
expect(() => {
33+
const result = analyzer.getViewerData(realWorldStats);
34+
expect(result).to.be.an('array');
35+
}).not.to.throw();
36+
});
37+
38+
it('should handle stats with only essential webpack 5 fields', function() {
39+
const webpack5MinimalStats = {
40+
version: "5.0.0",
41+
hash: "webpack5minimal",
42+
publicPath: "/",
43+
outputPath: "/build",
44+
chunks: [],
45+
entrypoints: {},
46+
// Common real-world scenario: missing assets and modules
47+
errors: [],
48+
warnings: [],
49+
namedChunkGroups: {}
50+
};
51+
52+
const result = analyzer.getViewerData(webpack5MinimalStats);
53+
expect(result).to.be.an('array').that.is.empty;
54+
});
55+
});

0 commit comments

Comments
 (0)