From ad4ff963fd9d5a8e50109dea46c6354319f5ca7f Mon Sep 17 00:00:00 2001 From: Evilebot Tnawi Date: Thu, 20 Dec 2018 20:34:16 +0300 Subject: [PATCH] test: `file-loader` should emit assets (#312) --- test/loader.test.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/test/loader.test.js b/test/loader.test.js index 7e1a963..3caa2e9 100644 --- a/test/loader.test.js +++ b/test/loader.test.js @@ -10,9 +10,24 @@ describe('loader', () => { }; const stats = await webpack('fixture.js', config); - const [module] = stats.toJson().modules; - const { source } = module; + const jsonStats = stats.toJson(); + const { modules, assets } = jsonStats; + const [{ source }] = modules; + + // eslint-disable-next-line no-new-func + const assetName = new Function( + 'exports', + 'require', + 'module', + '__filename', + '__dirname', + `'use strict'\nvar __webpack_public_path__ = '';\nreturn ${source}` + )(exports, require, module, __filename, __dirname); + const hasModuleAsAsset = Boolean( + assets.find((asset) => asset.name === assetName) + ); + expect(hasModuleAsAsset).toBe(true); expect(source).toMatchSnapshot(); });