aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/test-utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/test-utils.js')
-rw-r--r--test/unit/test-utils.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/unit/test-utils.js b/test/unit/test-utils.js
new file mode 100644
index 000000000..7d0ae4d91
--- /dev/null
+++ b/test/unit/test-utils.js
@@ -0,0 +1,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)
+ }
+}