From aeebe6a7bc90c182af560b7715596be7502d361e Mon Sep 17 00:00:00 2001 From: mrbar42 Date: Tue, 17 Aug 2021 15:36:12 +0300 Subject: [PATCH] fix tests runner in older node versions --- .github/workflows/pr.yml | 2 +- tests/runner.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 2db1ab0..60deed2 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [ '8', '12', '14', '16' ] + node: [ '8', '10', '12', '14', '16' ] name: Node ${{ matrix.node }} Tests steps: - uses: actions/checkout@v2 diff --git a/tests/runner.js b/tests/runner.js index 6c7f719..49de195 100644 --- a/tests/runner.js +++ b/tests/runner.js @@ -140,9 +140,14 @@ function asyncRunner() { let path = require.resolve(__dirname + '/' + test.child); let timer; let ended = false; + const args = [path]; // unhandled rejections default to throw since v15, warn since v10 // we make it the same for all versions so the result will be consistent. - let child = execFile('node', ["--unhandled-rejections=none", path], (err, stdout) => { + if (Number(process.version.substring(1).split('.')[0]) >= 10) { + args.unshift("--unhandled-rejections=none"); + } + + let child = execFile('node', args, (err, stdout) => { clearTimeout(timer); ended = true; if (err && /Error/.test(err.message)) {