-
-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add tests in case of warnings from loader
- Loading branch information
Showing
5 changed files
with
49 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
|
||
const { run } = require('../../utils/test-utils'); | ||
|
||
describe('loader warning test', () => { | ||
it(`should not ignore loader's warning and exit with a non zero exit code`, () => { | ||
const { stdout, exitCode } = run(__dirname, [], false); | ||
|
||
expect(stdout).toContain('This is a warning'); | ||
expect(exitCode).not.toEqual(0); | ||
}); | ||
}); |
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 = function loader(source) { | ||
const { emitWarning } = this; | ||
emitWarning('This is a warning'); | ||
return source; | ||
}; |
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('loader warning 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,30 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
mode: 'development', | ||
|
||
entry: { | ||
bundle: './src/main.js', | ||
}, | ||
|
||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: '[name].js', | ||
}, | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
test: /.(js|jsx)?$/, | ||
loader: 'my-loader', | ||
include: [path.resolve(__dirname, 'src')], | ||
exclude: [/node_modules/], | ||
}, | ||
], | ||
}, | ||
resolveLoader: { | ||
alias: { | ||
'my-loader': require.resolve('./my-loader'), | ||
}, | ||
}, | ||
}; |