streams/library/sodium-plus/test/async-helper.js
2024-03-14 14:49:12 +11:00

13 lines
333 B
JavaScript

const { expect } = require('chai');
module.exports = async function expectError(promised, message) {
let thrown = false;
try {
await promised;
} catch (e) {
thrown = true;
expect(message).to.be.equal(e.message);
}
if (!thrown) {
throw new Error('Function did not throw');
}
};