-
-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require('url'); | ||
require('path'); | ||
|
||
console.log('--no-stats with config test'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
// eslint-disable-next-line node/no-unpublished-require | ||
const { run } = require('../../utils/test-utils'); | ||
// eslint-disable-next-line node/no-extraneous-require | ||
const { version } = require('webpack'); | ||
|
||
describe('stats flag', () => { | ||
it(`should use stats detailed as defined in webpack config`, () => { | ||
const { stderr, stdout } = run(__dirname, []); | ||
|
||
expect(stderr).toBeFalsy(); | ||
if (version.startsWith('5')) { | ||
expect(stdout).toContain(`stats: { preset: 'detailed' }`); | ||
} else { | ||
expect(stdout).toContain(`stats: 'detailed'`); | ||
} | ||
}); | ||
|
||
it(`should use --no-stats and override value config`, () => { | ||
const { stderr, stdout } = run(__dirname, ['--no-stats']); | ||
|
||
expect(stderr).toBeFalsy(); | ||
if (version.startsWith('5')) { | ||
expect(stdout).toContain(`stats: { preset: 'none' }`); | ||
} else { | ||
expect(stdout).toContain(`stats: false`); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// eslint-disable-next-line node/no-unpublished-require | ||
const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); | ||
|
||
module.exports = { | ||
mode: 'development', | ||
entry: './main.js', | ||
stats: 'detailed', | ||
plugins: [new WebpackCLITestPlugin()], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require('url'); | ||
require('path'); | ||
|
||
console.log('--no-stats test'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
// eslint-disable-next-line node/no-unpublished-require | ||
const { run } = require('../../utils/test-utils'); | ||
// eslint-disable-next-line node/no-extraneous-require | ||
const { version } = require('webpack'); | ||
|
||
describe('stats flag', () => { | ||
it('should accept --no-stats as boolean', () => { | ||
const { stderr, stdout } = run(__dirname, ['--no-stats']); | ||
|
||
expect(stderr).toBeFalsy(); | ||
if (version.startsWith('5')) { | ||
expect(stdout).toContain(`stats: { preset: 'none' }`); | ||
} else { | ||
expect(stdout).toContain('stats: false'); | ||
} | ||
}); | ||
|
||
it('should warn and use --no-stats when stats and no-stats both are provided', () => { | ||
const { stderr, stdout } = run(__dirname, ['--stats', 'verbose', '--no-stats']); | ||
|
||
expect(stderr).toContain(`You provided both --stats and --no-stats. We will use only the last of these flags`); | ||
if (version.startsWith('5')) { | ||
expect(stdout).toContain(`stats: { preset: 'none' }`); | ||
} else { | ||
expect(stdout).toContain('stats: false'); | ||
} | ||
}); | ||
|
||
it('should warn and use --stats when stats and no-stats both are provided', () => { | ||
const { stderr, stdout } = run(__dirname, ['--no-stats', '--stats', 'verbose']); | ||
|
||
expect(stderr).toContain(`You provided both --stats and --no-stats. We will use only the last of these flags`); | ||
if (version.startsWith('5')) { | ||
expect(stdout).toContain(`stats: { preset: 'verbose' }`); | ||
} else { | ||
expect(stdout).toContain(`stats: 'verbose'`); | ||
} | ||
}); | ||
|
||
it('should use --verbose over --no-stats', () => { | ||
const { stderr, stdout } = run(__dirname, ['--no-stats', '--verbose']); | ||
|
||
expect(stderr).toBeFalsy(); | ||
if (version.startsWith('5')) { | ||
expect(stdout).toContain(`stats: { preset: 'verbose' }`); | ||
} else { | ||
expect(stdout).toContain(`stats: 'verbose'`); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// eslint-disable-next-line node/no-unpublished-require | ||
const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin'); | ||
|
||
module.exports = { | ||
mode: 'development', | ||
entry: './main.js', | ||
plugins: [new WebpackCLITestPlugin()], | ||
}; |