Skip to content

Commit 8b865fe

Browse files
test: source map (#1180)
1 parent ec58a7c commit 8b865fe

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

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

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`"sourceMap" option false should generate source maps when css was extracted: errors 1`] = `Array []`;
4+
5+
exports[`"sourceMap" option false should generate source maps when css was extracted: extracted css 1`] = `
6+
".nested {
7+
color: blue;
8+
}
9+
10+
.class {
11+
color: red;
12+
}
13+
14+
"
15+
`;
16+
17+
exports[`"sourceMap" option false should generate source maps when css was extracted: warnings 1`] = `Array []`;
18+
319
exports[`"sourceMap" option false should not generate source maps when previous loader does not generate source maps: errors 1`] = `Array []`;
420

521
exports[`"sourceMap" option false should not generate source maps when previous loader does not generate source maps: module 1`] = `

test/sourceMap-option.test.js

+43
Original file line numberDiff line numberDiff line change
@@ -742,5 +742,48 @@ describe('"sourceMap" option', () => {
742742
expect(getWarnings(stats)).toMatchSnapshot('warnings');
743743
expect(getErrors(stats)).toMatchSnapshot('errors');
744744
});
745+
746+
it('should generate source maps when css was extracted', async () => {
747+
const compiler = getCompiler(
748+
'./source-map/basic.js',
749+
{},
750+
{
751+
output: {
752+
path: path.resolve(__dirname, '../outputs'),
753+
filename: '[name].bundle.js',
754+
chunkFilename: '[name].chunk.js',
755+
publicPath: '/webpack/public/path/',
756+
},
757+
plugins: [
758+
new MiniCssExtractPlugin({
759+
filename: '[name].css',
760+
}),
761+
],
762+
module: {
763+
rules: [
764+
{
765+
test: /\.css$/i,
766+
rules: [
767+
{
768+
loader: MiniCssExtractPlugin.loader,
769+
},
770+
{
771+
loader: path.resolve(__dirname, '../src'),
772+
options: { sourceMap: false },
773+
},
774+
],
775+
},
776+
],
777+
},
778+
}
779+
);
780+
const stats = await compile(compiler);
781+
782+
expect(readAsset('main.css', compiler, stats)).toMatchSnapshot(
783+
'extracted css'
784+
);
785+
expect(getWarnings(stats)).toMatchSnapshot('warnings');
786+
expect(getErrors(stats)).toMatchSnapshot('errors');
787+
});
745788
});
746789
});

0 commit comments

Comments
 (0)