-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
emit-error.test.js
43 lines (33 loc) · 1.33 KB
/
emit-error.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import pack from './utils/pack';
describe('emit error', () => {
it('should not emit errors if emitError is false', async () => {
const compiler = pack('error', { emitError: false });
const stats = await compiler.runAsync();
expect(stats.hasErrors()).toBe(false);
});
it('should emit errors if emitError is undefined', async () => {
const compiler = pack('error', {});
const stats = await compiler.runAsync();
expect(stats.hasErrors()).toBe(true);
});
it('should emit errors if emitError is true', async () => {
const compiler = pack('error', { emitError: true });
const stats = await compiler.runAsync();
expect(stats.hasErrors()).toBe(true);
});
it('should emit errors, but not warnings if emitError is true and emitWarning is false', async () => {
const compiler = pack('full-of-problems', {
emitError: true,
emitWarning: false,
});
const stats = await compiler.runAsync();
expect(stats.hasWarnings()).toBe(false);
expect(stats.hasErrors()).toBe(true);
});
it('should emit errors and warnings if emitError is true and emitWarning is undefined', async () => {
const compiler = pack('full-of-problems', { emitError: true });
const stats = await compiler.runAsync();
expect(stats.hasWarnings()).toBe(true);
expect(stats.hasErrors()).toBe(true);
});
});