File tree Expand file tree Collapse file tree 2 files changed +12
-17
lines changed
packages/webpack-cli/lib/groups Expand file tree Collapse file tree 2 files changed +12
-17
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ class StatsGroup extends GroupHelper {
2727 this . opts . options . stats = this . args . stats ;
2828 }
2929 }
30+ if ( this . args . json ) {
31+ this . opts . outputOptions . json = true ;
32+ }
3033 }
3134
3235 run ( ) {
Original file line number Diff line number Diff line change 11'use strict' ;
2- const { join } = require ( 'path' ) ;
32const { run } = require ( '../utils/test-utils' ) ;
4- const webpack = require ( 'webpack' ) ;
53
64describe ( 'json flag' , ( ) => {
7- it . skip ( 'should match the snapshot of --json command' , async ( ) => {
8- const { stdout } = run ( __dirname , [ __dirname , '--json' ] ) ;
9- const jsonstdout = JSON . parse ( stdout ) ;
10- const compiler = await webpack ( {
11- entry : './index.js' ,
12- output : {
13- filename : 'main.js' ,
14- path : join ( __dirname , 'bin' ) ,
15- } ,
16- } ) ;
17- compiler . run ( ( err , stats ) => {
18- expect ( err ) . toBeFalsy ( ) ;
19- const webpackStats = stats . toJson ( { json : true } ) ;
20- expect ( jsonstdout ) . toEqual ( webpackStats ) ;
21- } ) ;
5+ it ( 'should return valid json' , ( ) => {
6+ const { stdout } = run ( __dirname , [ '--json' ] ) ;
7+
8+ // helper function to check if JSON is valid
9+ const parseJson = ( ) => {
10+ return JSON . parse ( stdout ) ;
11+ } ;
12+ // check the JSON is valid.
13+ expect ( parseJson ) . not . toThrow ( ) ;
2214 } ) ;
2315} ) ;
You can’t perform that action at this time.
0 commit comments