When testing my Typescript code, I encountered an issue where it should throw an error when no parameter is passed.
getID(ID) { if(!ID){throw new Error('stop js')} ....}
it('should fail if no ID', async () => {
expect(async () => await myService.getID() ).to.throw("stop js");
})
Even though the documentation suggests that the above code should work as expected, when running the test, I received this error message:
1) myTest
should fail if no groupId is passed:
AssertionError: expected [Function] to throw an error