Skip to content

Commit

Permalink
fix tests runner in older node versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbar42 committed Aug 17, 2021
1 parent a04c912 commit aeebe6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion tests/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit aeebe6a

Please sign in to comment.