File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed
Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments