-
-
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
6 changed files
with
66 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,17 @@ | ||
/* | ||
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). | ||
* This devtool is not neither made for production nor for readable output files. | ||
* It uses "eval()" calls to create a separate source file in the browser devtools. | ||
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) | ||
* or disable the default devtool with "devtool: false". | ||
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). | ||
*/ | ||
/******/ (() => { // webpackBootstrap | ||
/*!*********************!*\ | ||
!*** ./src/main.js ***! | ||
\*********************/ | ||
/*! unknown exports (runtime-defined) */ | ||
/*! runtime requirements: */ | ||
eval("console.log('loader warning test');\n\n\n//# sourceURL=webpack:///./src/main.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,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'), | ||
}, | ||
}, | ||
}; |