Skip to content

Commit 8321b87

Browse files
committed
Do not test --unhandled-rejections on Node <12
1 parent f7a4d8a commit 8321b87

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

test/helpers/events/version.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@ export const hasMultipleResolves = function() {
88
}
99

1010
const MULTIPLE_RESOLVES_V = '10.12.0'
11+
12+
// `--unhandled-rejections` was introduced in Node `12.0.0`
13+
export const hasUnhandledFlag = function() {
14+
return semver.gte(version, UNHANDLED_FLAG_V)
15+
}
16+
17+
const UNHANDLED_FLAG_V = '12.0.0'

test/warnings.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import sinon from 'sinon'
33
import testEach from 'test-each'
44

55
import { EVENTS, EVENTS_MAP } from './helpers/events/main.js'
6+
import { hasUnhandledFlag } from './helpers/events/version.js'
67
import { startLogging } from './helpers/init.js'
78
import { normalizeMessage, normalizeCall } from './helpers/normalize.js'
89
import { removeProcessListeners } from './helpers/remove.js'
@@ -57,13 +58,13 @@ test.serial(
5758
},
5859
)
5960

61+
const UNHANDLED_FLAGS = hasUnhandledFlag()
62+
? ['--unhandled-rejections=none', '--unhandled-rejections=strict']
63+
: []
64+
6065
testEach(
6166
EVENTS,
62-
[
63-
'--no-warnings',
64-
'--unhandled-rejections=none',
65-
'--unhandled-rejections=strict',
66-
],
67+
['--no-warnings', ...UNHANDLED_FLAGS],
6768
({ title }, { eventName }, flag) => {
6869
test(`should work with warnings-related CLI flags | ${title}`, async t => {
6970
t.snapshot(

0 commit comments

Comments
 (0)