-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
I have a beforeSave trigger that validates objects and throws errors if they fail validation. I want to test that this validation is working as expected.
I can't figure out how to catch the exception / error and prevent Jasmine from failing. Even if I try a structure like this, Jasmine fails early, the catch() block is never even called. I suspect because it's catching the console error thrown by the server backend first. I would have expected the spyOn function to catch that.
// ...
beforeEach((done) => {
spyOn(console, 'error');
dropDB()
.then(done).catch(done.fail);
});
// ...
it('should reject invalid items', async (done) => {
// Set up an `item` for saving.
try {
await item.save(null, {sessionToken: user.getSessionToken()})
}
catch (error) {
// check error, etc. This is never even called, even though beforeSave is definitely throwing an exception.
done();
}
}Metadata
Metadata
Assignees
Labels
No labels