Skip to content

Commit 3bcfd57

Browse files
test: output source map
1 parent affe574 commit 3bcfd57

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

test/__snapshots__/sourceMap-option.test.js.snap

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,49 @@ Array [
262262

263263
exports[`"sourceMap" option true should generate source maps and do not change "[contenthash]" on different platform: warnings 1`] = `Array []`;
264264

265+
exports[`"sourceMap" option true should generate source maps when css was extracted and do not change "[contenthash]" on different platform: errors 1`] = `Array []`;
266+
267+
exports[`"sourceMap" option true should generate source maps when css was extracted and do not change "[contenthash]" on different platform: extracted css 1`] = `
268+
".nested {
269+
color: blue;
270+
}
271+
272+
.class {
273+
color: red;
274+
}
275+
276+
277+
/*# sourceMappingURL=main.xxxxxxxxxxxxxxxxxxxx.css.map*/"
278+
`;
279+
280+
exports[`"sourceMap" option true should generate source maps when css was extracted and do not change "[contenthash]" on different platform: source map 1`] = `
281+
Object {
282+
"file": "main.xxxxxxxxxxxxxxxxxxxx.css",
283+
"mappings": "AAAA;EACE,WAAW;AACb;;ACAA;EACE,UAAU;AACZ",
284+
"names": Array [],
285+
"sourceRoot": "",
286+
"sources": Array [
287+
"webpack:///test/fixtures/source-map/nested/nested.css",
288+
"webpack:///test/fixtures/source-map/basic.css",
289+
],
290+
"sourcesContent": Array [
291+
".nested {
292+
color: blue;
293+
}
294+
",
295+
"@import \\"./nested/nested.css\\";
296+
297+
.class {
298+
color: red;
299+
}
300+
",
301+
],
302+
"version": 3,
303+
}
304+
`;
305+
306+
exports[`"sourceMap" option true should generate source maps when css was extracted and do not change "[contenthash]" on different platform: warnings 1`] = `Array []`;
307+
265308
exports[`"sourceMap" option true should generate source maps when css was extracted: errors 1`] = `Array []`;
266309

267310
exports[`"sourceMap" option true should generate source maps when css was extracted: extracted css 1`] = `

test/sourceMap-option.test.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,12 +482,16 @@ describe('"sourceMap" option', () => {
482482
expect(getErrors(stats)).toMatchSnapshot('errors');
483483
});
484484

485-
it.skip('should generate source maps when css was extracted and do not change "[contenthash]" on different platform', async () => {
485+
it('should generate source maps when css was extracted and do not change "[contenthash]" on different platform', async () => {
486486
const compiler = getCompiler(
487487
'./source-map/basic.js',
488488
{},
489489
{
490490
devtool: 'source-map',
491+
// webpack@4 has bug
492+
// It uses readableIdentifier to generate the sources, which uses the RequestShortener,
493+
// which has some problems with paths that are 2 folders above the context
494+
context: path.resolve(__dirname, '..'),
491495
output: {
492496
path: path.resolve(__dirname, '../outputs'),
493497
filename: '[name].bundle.js',
@@ -526,8 +530,8 @@ describe('"sourceMap" option', () => {
526530

527531
expect(chunkName).toBe(
528532
webpack.version[0] === '5'
529-
? 'main.93ca7a8226bf6b9e8275.css'
530-
: 'main.7232fe75dbf29c350324.css'
533+
? 'main.8189c1c4f956dd69079a.css'
534+
: 'main.6aa45a5434fd0e992559.css'
531535
);
532536

533537
expect(

0 commit comments

Comments
 (0)