diff --git a/test/fixtures/module-missing-loader-error/existing.json b/test/fixtures/module-missing-loader-error/existing.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/fixtures/module-missing-loader-error/existing.json @@ -0,0 +1 @@ +{} diff --git a/test/fixtures/module-missing-loader-error/index.js b/test/fixtures/module-missing-loader-error/index.js new file mode 100644 index 0000000..7dd3846 --- /dev/null +++ b/test/fixtures/module-missing-loader-error/index.js @@ -0,0 +1 @@ +require('./existing.json'); diff --git a/test/fixtures/module-missing-loader-error/webpack.config.js b/test/fixtures/module-missing-loader-error/webpack.config.js new file mode 100644 index 0000000..96ace55 --- /dev/null +++ b/test/fixtures/module-missing-loader-error/webpack.config.js @@ -0,0 +1,21 @@ + +const FriendlyErrorsWebpackPlugin = require('../../../index'); + +module.exports = { + entry: __dirname + "/index.js", + output: { + path: __dirname + "/dist", + filename: "bundle.js" + }, + module: { + rules: [ + { + test: /\.json$/, + loader: 'missing-loader', + }, + ] + }, + plugins: [ + new FriendlyErrorsWebpackPlugin() + ] +}; diff --git a/test/integration.spec.js b/test/integration.spec.js index 6882a91..b5f8e32 100644 --- a/test/integration.spec.js +++ b/test/integration.spec.js @@ -131,3 +131,20 @@ it('integration : webpack multi compiler : module-errors', async() => { 'Did you forget to run npm install --save for them?' ]); }); + +it('integration : missing loader', async() => { + + // We apply the plugin directly to the compiler when targeting multi-compiler + let globalPlugins = [new FriendlyErrorsWebpackPlugin()]; + const logs = await executeAndGetLogs('./fixtures/module-missing-loader-error/webpack.config', globalPlugins); + + expect(logs).toEqual([ + 'ERROR Failed to compile with 1 errors', + '', + 'This dependency was not found in node_modules:', + '', + '* missing-loader in ./test/fixtures/module-missing-loader-error/index.js', + '', + 'Install the missing loader with: npm install --save missing-loader' + ]); +});