mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-24 11:01:41 +01:00
18 lines
304 B
JavaScript
18 lines
304 B
JavaScript
|
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)
|
||
|
}
|
||
|
}
|