Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.

Commit ad4ff96

Browse files
test: file-loader should emit assets (#312)
1 parent 6dcc7e8 commit ad4ff96

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

test/loader.test.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,24 @@ describe('loader', () => {
1010
};
1111

1212
const stats = await webpack('fixture.js', config);
13-
const [module] = stats.toJson().modules;
14-
const { source } = module;
13+
const jsonStats = stats.toJson();
14+
const { modules, assets } = jsonStats;
15+
const [{ source }] = modules;
16+
17+
// eslint-disable-next-line no-new-func
18+
const assetName = new Function(
19+
'exports',
20+
'require',
21+
'module',
22+
'__filename',
23+
'__dirname',
24+
`'use strict'\nvar __webpack_public_path__ = '';\nreturn ${source}`
25+
)(exports, require, module, __filename, __dirname);
26+
const hasModuleAsAsset = Boolean(
27+
assets.find((asset) => asset.name === assetName)
28+
);
1529

30+
expect(hasModuleAsAsset).toBe(true);
1631
expect(source).toMatchSnapshot();
1732
});
1833

0 commit comments

Comments
 (0)