aboutsummaryrefslogblamecommitdiffstats
path: root/test/unit/test-utils.js
blob: 7d0ae4d91a2caddea98ac4418bc5dd2e9f450dea (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                                
const assert = require('assert')

module.exports = {
  assertRejects,
}

// assert.rejects added in node v10
async function assertRejects (asyncFn, regExp) {
  let f = () => {}
  try {
    await asyncFn()
  } catch (error) {
    f = () => { throw error }
  } finally {
    assert.throws(f, regExp)
  }
}