Skip to content

Commit 26680b0

Browse files
committed
Get the compiled source map object from within a test
1 parent 68bd963 commit 26680b0

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/sourceMap-option.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,26 @@ describe('sourceMap option', () => {
1515
const { modules } = stats.toJson();
1616
const module = modules.find((m) => m.id === testId);
1717

18+
/**
19+
* Get the actual source map from the OriginalSource object.
20+
* @see {@link https://github.com/webpack/webpack-sources}
21+
* @todo check that the source map exists
22+
* @todo check that the source map has valid and expected property values.
23+
*/
24+
const compilationModules = stats.compilation.modules;
25+
const compilationModule = compilationModules.find((m) => m.id === testId);
26+
const moduleOriginalSource = compilationModule._source; // eslint-disable-line no-underscore-dangle
27+
const moduleSourceMap = moduleOriginalSource.map();
28+
29+
/**
30+
* @todo remove `console.log` statments
31+
*/
32+
/* eslint-disable no-console */
33+
console.log('==========================================================');
34+
console.log(moduleSourceMap);
35+
console.log('==========================================================');
36+
/* eslint-enable no-console */
37+
1838
expect(normalizeSourceMap(evaluated(module.source))).toMatchSnapshot(
1939
'module (evaluated)'
2040
);

0 commit comments

Comments
 (0)