Skip to content

Commit

Permalink
test: source map (#1180)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Aug 25, 2020
1 parent ec58a7c commit 8b865fe
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/__snapshots__/sourceMap-option.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`"sourceMap" option false should generate source maps when css was extracted: errors 1`] = `Array []`;

exports[`"sourceMap" option false should generate source maps when css was extracted: extracted css 1`] = `
".nested {
color: blue;
}
.class {
color: red;
}
"
`;

exports[`"sourceMap" option false should generate source maps when css was extracted: warnings 1`] = `Array []`;

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

exports[`"sourceMap" option false should not generate source maps when previous loader does not generate source maps: module 1`] = `
Expand Down
43 changes: 43 additions & 0 deletions test/sourceMap-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -742,5 +742,48 @@ describe('"sourceMap" option', () => {
expect(getWarnings(stats)).toMatchSnapshot('warnings');
expect(getErrors(stats)).toMatchSnapshot('errors');
});

it('should generate source maps when css was extracted', async () => {
const compiler = getCompiler(
'./source-map/basic.js',
{},
{
output: {
path: path.resolve(__dirname, '../outputs'),
filename: '[name].bundle.js',
chunkFilename: '[name].chunk.js',
publicPath: '/webpack/public/path/',
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
}),
],
module: {
rules: [
{
test: /\.css$/i,
rules: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: path.resolve(__dirname, '../src'),
options: { sourceMap: false },
},
],
},
],
},
}
);
const stats = await compile(compiler);

expect(readAsset('main.css', compiler, stats)).toMatchSnapshot(
'extracted css'
);
expect(getWarnings(stats)).toMatchSnapshot('warnings');
expect(getErrors(stats)).toMatchSnapshot('errors');
});
});
});

0 comments on commit 8b865fe

Please sign in to comment.