Skip to content

Commit 5c960dd

Browse files
author
Edwin Zhang
committed
test/Warnings.test.js: add test for emitting warnings as errors
1 parent 823e596 commit 5c960dd

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

test/Warnings.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,29 @@ describe('Warnings', () => {
3030
expect(message).toMatchSnapshot()
3131
})
3232
})
33+
34+
test('Emit as Error', () => {
35+
const config = {
36+
loader: {
37+
test: /\.css$/,
38+
options: {
39+
emitWarningsAsErrors: true,
40+
plugins: [
41+
plugin()
42+
]
43+
}
44+
}
45+
}
46+
47+
return webpack('css/index.js', config).then((stats) => {
48+
const error = stats.compilation.errors[0]
49+
50+
const message = error.message
51+
.split('\n')
52+
.slice(1)
53+
.join('\n')
54+
55+
expect(message).toMatchSnapshot()
56+
})
57+
})
3358
})

test/__snapshots__/Warnings.test.js.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`Warnings Emit as Error 1`] = `
4+
"Warning
5+
6+
(1:5) <Message>"
7+
`;
8+
39
exports[`Warnings Plugins 1`] = `
410
"Warning
511

0 commit comments

Comments
 (0)