Skip to content

Commit 4a85f28

Browse files
committed
ci: fix unit tests for "sourceMap-option"
1 parent 3065917 commit 4a85f28

File tree

2 files changed

+34
-36
lines changed

2 files changed

+34
-36
lines changed
Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,51 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`when applied with "sourceMap" option matches snapshot for "false" value, using previous sourcemap: entry.547643882ea6ea7bc148.css 1`] = `"body{font-weight:700;color:red}body a{text-align:center}"`;
3+
exports[`when applied with "sourceMap" option matches snapshot for "false" value, using previous sourcemap: entry.css 1`] = `"body{font-weight:700;color:red}body a{text-align:center}"`;
44

5-
exports[`when applied with "sourceMap" option matches snapshot for "false" value, using previous sourcemap: entry2.60984d0692ef03342bf5.css 1`] = `"body{font-weight:700;color:red}body a{text-align:center}"`;
5+
exports[`when applied with "sourceMap" option matches snapshot for "false" value, using previous sourcemap: entry2.css 1`] = `"body{font-weight:700;color:red}body a{text-align:center}"`;
66

7-
exports[`when applied with "sourceMap" option matches snapshot for "false" value, without previous sourcemap: entry.933a5a84fbf8d7c62ac4.css 1`] = `"body{font-weight:700;color:red}body a{text-align:center}"`;
7+
exports[`when applied with "sourceMap" option matches snapshot for "false" value, without previous sourcemap: entry.css 1`] = `"body{font-weight:700;color:red}body a{text-align:center}"`;
88

9-
exports[`when applied with "sourceMap" option matches snapshot for "false" value, without previous sourcemap: entry2.540d594073fd3d6b52ae.css 1`] = `"body{font-weight:700;color:red}body a{text-align:center}"`;
9+
exports[`when applied with "sourceMap" option matches snapshot for "false" value, without previous sourcemap: entry2.css 1`] = `"body{font-weight:700;color:red}body a{text-align:center}"`;
1010

11-
exports[`when applied with "sourceMap" option matches snapshot for "inline" value: entry.547643882ea6ea7bc148.css 1`] = `
11+
exports[`when applied with "sourceMap" option matches snapshot for "true" value, using previous sourcemap: entry.css 1`] = `
1212
"body{font-weight:700;color:red}body a{text-align:center}
13-
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkQ6L3dvcmsvd2VicGFjay9jc3NuYW5vLXdlYnBhY2stcGx1Z2luL3Rlc3QvZml4dHVyZXMvc291cmNlbWFwL2Jhci5zY3NzIiwiRDovd29yay93ZWJwYWNrL2Nzc25hbm8td2VicGFjay1wbHVnaW4vdGVzdC9maXh0dXJlcy9zb3VyY2VtYXAvZm9vLnNjc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsS0FDRSxlQUFBLENDRUEsU0RGaUIsQ0NDbkIsT0FHSSxpQkFBa0IiLCJmaWxlIjoiZW50cnkuNTQ3NjQzODgyZWE2ZWE3YmMxNDguY3NzIiwic291cmNlc0NvbnRlbnQiOlsiYm9keSB7XG4gIGZvbnQtd2VpZ2h0OiBib2xkO1xufSIsIkBpbXBvcnQgJ2Jhcic7XG5cbmJvZHkge1xuICBjb2xvcjogcmVkO1xuICBhIHtcbiAgICB0ZXh0LWFsaWduOiBjZW50ZXI7XG4gIH1cbn0iXX0= */"
13+
/*# sourceMappingURL=entry.css.map*/"
1414
`;
1515

16-
exports[`when applied with "sourceMap" option matches snapshot for "inline" value: entry2.60984d0692ef03342bf5.css 1`] = `
17-
"body{font-weight:700;color:red}body a{text-align:center}
18-
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkQ6L3dvcmsvd2VicGFjay9jc3NuYW5vLXdlYnBhY2stcGx1Z2luL3Rlc3QvZml4dHVyZXMvc291cmNlbWFwL2Jhci5zY3NzIiwiRDovd29yay93ZWJwYWNrL2Nzc25hbm8td2VicGFjay1wbHVnaW4vdGVzdC9maXh0dXJlcy9zb3VyY2VtYXAvZm9vLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxLQUNFLGVBQUEsQ0NFQSxTREZpQixDQ0dsQixPQUdDLGlCQUFrQiIsImZpbGUiOiJlbnRyeTIuNjA5ODRkMDY5MmVmMDMzNDJiZjUuY3NzIiwic291cmNlc0NvbnRlbnQiOlsiYm9keSB7XG4gIGZvbnQtd2VpZ2h0OiBib2xkO1xufSIsIkBpbXBvcnQgJ2Jhcic7XG5cbmJvZHkge1xuICBjb2xvcjogcmVkO1xufVxuXG5ib2R5IGEge1xuICB0ZXh0LWFsaWduOiBjZW50ZXI7XG59Il19 */"
19-
`;
20-
21-
exports[`when applied with "sourceMap" option matches snapshot for "true" value, using previous sourcemap: entry.547643882ea6ea7bc148.css 1`] = `
22-
"body{font-weight:700;color:red}body a{text-align:center}
23-
/*# sourceMappingURL=entry.547643882ea6ea7bc148.css.map*/"
24-
`;
25-
26-
exports[`when applied with "sourceMap" option matches snapshot for "true" value, using previous sourcemap: entry.547643882ea6ea7bc148.css.map 1`] = `"{\\"version\\":3,\\"sources\\":[\\"webpack:///./test/fixtures/sourcemap/bar.scss\\",\\"webpack:///./test/fixtures/sourcemap/foo.scss\\"],\\"names\\":[],\\"mappings\\":\\"AAAA,KACE,gBCEA,SDFiB,CCCnB,OAGI,iBAAkB\\",\\"file\\":\\"entry.547643882ea6ea7bc148.css\\",\\"sourcesContent\\":[\\"body {\\\\n font-weight: bold;\\\\n}\\",\\"@import 'bar';\\\\n\\\\nbody {\\\\n color: red;\\\\n a {\\\\n text-align: center;\\\\n }\\\\n}\\"],\\"sourceRoot\\":\\"\\"}"`;
16+
exports[`when applied with "sourceMap" option matches snapshot for "true" value, using previous sourcemap: entry.css.map 1`] = `"{\\"version\\":3,\\"sources\\":[\\"webpack:///./test/fixtures/sourcemap/bar.scss\\",\\"webpack:///./test/fixtures/sourcemap/foo.scss\\"],\\"names\\":[],\\"mappings\\":\\"AAAA,KACE,gBCEA,SDFiB,CCCnB,OAGI,iBAAkB\\",\\"file\\":\\"entry.css\\",\\"sourcesContent\\":[\\"body {\\\\n font-weight: bold;\\\\n}\\",\\"@import 'bar';\\\\n\\\\nbody {\\\\n color: red;\\\\n a {\\\\n text-align: center;\\\\n }\\\\n}\\"],\\"sourceRoot\\":\\"\\"}"`;
2717

28-
exports[`when applied with "sourceMap" option matches snapshot for "true" value, using previous sourcemap: entry2.60984d0692ef03342bf5.css 1`] = `
18+
exports[`when applied with "sourceMap" option matches snapshot for "true" value, using previous sourcemap: entry2.css 1`] = `
2919
"body{font-weight:700;color:red}body a{text-align:center}
30-
/*# sourceMappingURL=entry2.60984d0692ef03342bf5.css.map*/"
20+
/*# sourceMappingURL=entry2.css.map*/"
3121
`;
3222

33-
exports[`when applied with "sourceMap" option matches snapshot for "true" value, using previous sourcemap: entry2.60984d0692ef03342bf5.css.map 1`] = `"{\\"version\\":3,\\"sources\\":[\\"webpack:///./test/fixtures/sourcemap/bar.scss\\",\\"webpack:///./test/fixtures/sourcemap/foo.css\\"],\\"names\\":[],\\"mappings\\":\\"AAAA,KACE,gBCEA,SDFiB,CCGlB,OAGC,iBAAkB\\",\\"file\\":\\"entry2.60984d0692ef03342bf5.css\\",\\"sourcesContent\\":[\\"body {\\\\n font-weight: bold;\\\\n}\\",\\"@import 'bar';\\\\n\\\\nbody {\\\\n color: red;\\\\n}\\\\n\\\\nbody a {\\\\n text-align: center;\\\\n}\\"],\\"sourceRoot\\":\\"\\"}"`;
23+
exports[`when applied with "sourceMap" option matches snapshot for "true" value, using previous sourcemap: entry2.css.map 1`] = `"{\\"version\\":3,\\"sources\\":[\\"webpack:///./test/fixtures/sourcemap/bar.scss\\",\\"webpack:///./test/fixtures/sourcemap/foo.css\\"],\\"names\\":[],\\"mappings\\":\\"AAAA,KACE,gBCEA,SDFiB,CCGlB,OAGC,iBAAkB\\",\\"file\\":\\"entry2.css\\",\\"sourcesContent\\":[\\"body {\\\\n font-weight: bold;\\\\n}\\",\\"@import 'bar';\\\\n\\\\nbody {\\\\n color: red;\\\\n}\\\\n\\\\nbody a {\\\\n text-align: center;\\\\n}\\"],\\"sourceRoot\\":\\"\\"}"`;
3424

35-
exports[`when applied with "sourceMap" option matches snapshot for "true" value, without previous sourcemap: entry.933a5a84fbf8d7c62ac4.css 1`] = `
25+
exports[`when applied with "sourceMap" option matches snapshot for "true" value, without previous sourcemap: entry.css 1`] = `
3626
"body{font-weight:700;color:red}body a{text-align:center}
37-
/*# sourceMappingURL=entry.933a5a84fbf8d7c62ac4.css.map*/"
27+
/*# sourceMappingURL=entry.css.map*/"
3828
`;
3929

40-
exports[`when applied with "sourceMap" option matches snapshot for "true" value, without previous sourcemap: entry.933a5a84fbf8d7c62ac4.css.map 1`] = `"{\\"version\\":3,\\"sources\\":[\\"webpack:///./test/fixtures/sourcemap/foo.scss\\"],\\"names\\":[],\\"mappings\\":\\"AAAA,KAAK,gBAAsB,SAAtB,CAAgC,OAAO\\",\\"file\\":\\"entry.933a5a84fbf8d7c62ac4.css\\",\\"sourcesContent\\":[\\"body{font-weight:bold}body{color:red}body a{text-align:center}\\\\n\\"],\\"sourceRoot\\":\\"\\"}"`;
30+
exports[`when applied with "sourceMap" option matches snapshot for "true" value, without previous sourcemap: entry.css.map 1`] = `"{\\"version\\":3,\\"sources\\":[\\"webpack:///./test/fixtures/sourcemap/foo.scss\\"],\\"names\\":[],\\"mappings\\":\\"AAAA,KAAK,gBAAsB,SAAtB,CAAgC,OAAO\\",\\"file\\":\\"entry.css\\",\\"sourcesContent\\":[\\"body{font-weight:bold}body{color:red}body a{text-align:center}\\\\n\\"],\\"sourceRoot\\":\\"\\"}"`;
4131

42-
exports[`when applied with "sourceMap" option matches snapshot for "true" value, without previous sourcemap: entry2.540d594073fd3d6b52ae.css 1`] = `
32+
exports[`when applied with "sourceMap" option matches snapshot for "true" value, without previous sourcemap: entry2.css 1`] = `
4333
"body{font-weight:700;color:red}body a{text-align:center}
44-
/*# sourceMappingURL=entry2.540d594073fd3d6b52ae.css.map*/"
34+
/*# sourceMappingURL=entry2.css.map*/"
4535
`;
4636

47-
exports[`when applied with "sourceMap" option matches snapshot for "true" value, without previous sourcemap: entry2.540d594073fd3d6b52ae.css.map 1`] = `"{\\"version\\":3,\\"sources\\":[\\"webpack:///./test/fixtures/sourcemap/foo.css\\"],\\"names\\":[],\\"mappings\\":\\"AAAA,KAAK,gBAAsB,SAAtB,CAAgC,OAAO\\",\\"file\\":\\"entry2.540d594073fd3d6b52ae.css\\",\\"sourcesContent\\":[\\"body{font-weight:bold}body{color:red}body a{text-align:center}\\\\n\\"],\\"sourceRoot\\":\\"\\"}"`;
37+
exports[`when applied with "sourceMap" option matches snapshot for "true" value, without previous sourcemap: entry2.css.map 1`] = `"{\\"version\\":3,\\"sources\\":[\\"webpack:///./test/fixtures/sourcemap/foo.css\\"],\\"names\\":[],\\"mappings\\":\\"AAAA,KAAK,gBAAsB,SAAtB,CAAgC,OAAO\\",\\"file\\":\\"entry2.css\\",\\"sourcesContent\\":[\\"body{font-weight:bold}body{color:red}body a{text-align:center}\\\\n\\"],\\"sourceRoot\\":\\"\\"}"`;
4838

49-
exports[`when applied with "sourceMap" option matches snapshot when using SourceMapDevToolPlugin (with filename, publicPath and fileContext options): dist/entry.547643882ea6ea7bc148.css 1`] = `
39+
exports[`when applied with "sourceMap" option matches snapshot when using SourceMapDevToolPlugin (with filename, publicPath and fileContext options): dist/entry.css 1`] = `
5040
"body{font-weight:700;color:red}body a{text-align:center}
51-
/*# sourceMappingURL=https://example.com/project/sourcemaps/entry.547643882ea6ea7bc148.css.map*/"
41+
/*# sourceMappingURL=https://example.com/project/sourcemaps/entry.css.map*/"
5242
`;
5343

54-
exports[`when applied with "sourceMap" option matches snapshot when using SourceMapDevToolPlugin (with filename, publicPath and fileContext options): dist/entry2.60984d0692ef03342bf5.css 1`] = `
44+
exports[`when applied with "sourceMap" option matches snapshot when using SourceMapDevToolPlugin (with filename, publicPath and fileContext options): dist/entry2.css 1`] = `
5545
"body{font-weight:700;color:red}body a{text-align:center}
56-
/*# sourceMappingURL=https://example.com/project/sourcemaps/entry2.60984d0692ef03342bf5.css.map*/"
46+
/*# sourceMappingURL=https://example.com/project/sourcemaps/entry2.css.map*/"
5747
`;
5848

59-
exports[`when applied with "sourceMap" option matches snapshot when using SourceMapDevToolPlugin (with filename, publicPath and fileContext options): sourcemaps/entry.547643882ea6ea7bc148.css.map 1`] = `"{\\"version\\":3,\\"sources\\":[\\"webpack:///./test/fixtures/sourcemap/bar.scss\\",\\"webpack:///./test/fixtures/sourcemap/foo.scss\\"],\\"names\\":[],\\"mappings\\":\\"AAAA,KACE,gBCEA,SDFiB,CCCnB,OAGI,iBAAkB\\",\\"file\\":\\"dist/entry.547643882ea6ea7bc148.css\\",\\"sourcesContent\\":[\\"body {\\\\n font-weight: bold;\\\\n}\\",\\"@import 'bar';\\\\n\\\\nbody {\\\\n color: red;\\\\n a {\\\\n text-align: center;\\\\n }\\\\n}\\"],\\"sourceRoot\\":\\"\\"}"`;
49+
exports[`when applied with "sourceMap" option matches snapshot when using SourceMapDevToolPlugin (with filename, publicPath and fileContext options): sourcemaps/entry.css.map 1`] = `"{\\"version\\":3,\\"sources\\":[\\"webpack:///./test/fixtures/sourcemap/bar.scss\\",\\"webpack:///./test/fixtures/sourcemap/foo.scss\\"],\\"names\\":[],\\"mappings\\":\\"AAAA,KACE,gBCEA,SDFiB,CCCnB,OAGI,iBAAkB\\",\\"file\\":\\"dist/entry.css\\",\\"sourcesContent\\":[\\"body {\\\\n font-weight: bold;\\\\n}\\",\\"@import 'bar';\\\\n\\\\nbody {\\\\n color: red;\\\\n a {\\\\n text-align: center;\\\\n }\\\\n}\\"],\\"sourceRoot\\":\\"\\"}"`;
6050

61-
exports[`when applied with "sourceMap" option matches snapshot when using SourceMapDevToolPlugin (with filename, publicPath and fileContext options): sourcemaps/entry2.60984d0692ef03342bf5.css.map 1`] = `"{\\"version\\":3,\\"sources\\":[\\"webpack:///./test/fixtures/sourcemap/bar.scss\\",\\"webpack:///./test/fixtures/sourcemap/foo.css\\"],\\"names\\":[],\\"mappings\\":\\"AAAA,KACE,gBCEA,SDFiB,CCGlB,OAGC,iBAAkB\\",\\"file\\":\\"dist/entry2.60984d0692ef03342bf5.css\\",\\"sourcesContent\\":[\\"body {\\\\n font-weight: bold;\\\\n}\\",\\"@import 'bar';\\\\n\\\\nbody {\\\\n color: red;\\\\n}\\\\n\\\\nbody a {\\\\n text-align: center;\\\\n}\\"],\\"sourceRoot\\":\\"\\"}"`;
51+
exports[`when applied with "sourceMap" option matches snapshot when using SourceMapDevToolPlugin (with filename, publicPath and fileContext options): sourcemaps/entry2.css.map 1`] = `"{\\"version\\":3,\\"sources\\":[\\"webpack:///./test/fixtures/sourcemap/bar.scss\\",\\"webpack:///./test/fixtures/sourcemap/foo.css\\"],\\"names\\":[],\\"mappings\\":\\"AAAA,KACE,gBCEA,SDFiB,CCGlB,OAGC,iBAAkB\\",\\"file\\":\\"dist/entry2.css\\",\\"sourcesContent\\":[\\"body {\\\\n font-weight: bold;\\\\n}\\",\\"@import 'bar';\\\\n\\\\nbody {\\\\n color: red;\\\\n}\\\\n\\\\nbody a {\\\\n text-align: center;\\\\n}\\"],\\"sourceRoot\\":\\"\\"}"`;

test/sourceMap-option.test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ describe('when applied with "sourceMap" option', () => {
1818
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
1919
}
2020
]
21-
}
21+
},
22+
plugins: [
23+
new MiniCssExtractPlugin({
24+
filename: '[name].css',
25+
chunkFilename: '[id].[name].css'
26+
})
27+
]
2228
};
2329

2430
it('matches snapshot for "false" value, without previous sourcemap', () => {
@@ -129,7 +135,9 @@ describe('when applied with "sourceMap" option', () => {
129135

130136
for (const file in stats.compilation.assets) {
131137
if (/\.js/.test(file)) continue;
132-
expect(stats.compilation.assets[file].source()).toMatchSnapshot(file);
138+
const { source, map } = stats.compilation.assets[file].sourceAndMap();
139+
expect(map).toBeNull();
140+
expect(source).toMatch(/\/\*# sourceMappingURL=data:application\/json;base64,.*\*\//);
133141
}
134142
});
135143
});
@@ -151,8 +159,8 @@ describe('when applied with "sourceMap" option', () => {
151159
},
152160
plugins: [
153161
new MiniCssExtractPlugin({
154-
filename: 'dist/[name].[chunkhash].css',
155-
chunkFilename: 'dist/[id].[name].[chunkhash].css'
162+
filename: 'dist/[name].css',
163+
chunkFilename: 'dist/[id].[name].css'
156164
}),
157165
new webpack.SourceMapDevToolPlugin({
158166
filename: 'sourcemaps/[file].map',

0 commit comments

Comments
 (0)