Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: for exit-code in case of error in config (#1979)
- Loading branch information
Showing
6 changed files
with
33 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
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ test/**/dist/ | |
test/**/bin/ | ||
test/**/binary/ | ||
test/**/index.js | ||
test/config/error/syntax-error.js |
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,20 @@ | ||
'use strict'; | ||
const { resolve } = require('path'); | ||
const { run } = require('../../utils/test-utils'); | ||
|
||
describe('config error', () => { | ||
it('should throw error with invalid configuration', () => { | ||
const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); | ||
|
||
expect(stderr).toContain('Invalid configuration object'); | ||
expect(stderr).toContain(`"development" | "production" | "none"`); | ||
expect(exitCode).toBe(2); | ||
}); | ||
|
||
it('should throw syntax error and exit with non-zero exit code', () => { | ||
const { stderr, exitCode } = run(__dirname, ['-c', resolve(__dirname, 'syntax-error.js')]); | ||
|
||
expect(stderr).toContain('SyntaxError: Unexpected token'); | ||
expect(exitCode).toBe(2); | ||
}); | ||
}); |
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 @@ | ||
console.log('config error 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,5 @@ | ||
module.exports = { | ||
name: 'config-error', | ||
mode: 'development', | ||
target: 'node'; //SyntaxError: Unexpected token ';' | ||
}; |
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,5 @@ | ||
module.exports = { | ||
name: 'config-error', | ||
mode: 'unknown', //error | ||
target: 'node', | ||
}; |