Reputation: 37
Receiving issues on trying to assert an error message for the test case
AssertionError: expected [Function] to throw an error
at Context.it (test\index.js:24:80)
if (configVms.rts) {
describe('Real Time Services', () => {
for(let rtsConfig of configVms["rts"].rtsConfig) {
it(`Real Time Services endpoints for guid ${rtsConfig.resourceId} on ${rtsConfig.platformType} platform`, async () => {
expect(async () => await realTimeServices.main(rtsConfig)).to.throw('Host rejected');
});
}});
}
Upvotes: 0
Views: 37
Reputation: 1839
to.throw
is applicable only to synchronous functions.
In your case I would recommend to add chai-as-promised
plugin and change test:
if (configVms.rts) {
describe('Real Time Services', () => {
for(let rtsConfig of configVms["rts"].rtsConfig) {
it(`Real Time Services endpoints for guid ${rtsConfig.resourceId} on ${rtsConfig.platformType} platform`, async () => {
await expect(realTimeServices.main(rtsConfig)).to.be.rejectedWith('Host rejected');
});
}});
}
Upvotes: 2