javascript - How can I write a test which expects an 'Error' to be thrown in Jasmine?
I'm trying to write a test for the Jasmine Test Framework which expects an error. At the moment I'm using a Jasmine Node.js integration from GitHub.
In my Node.js module I have the following code:
throw new Error("Parsing is not possible");
Now I try to write a test which expects this error:
describe('my suite...', function() {
[..]
it('should not parse foo', function() {
[..]
expect(parser.parse(raw)).toThrow(new Error("Parsing is not possible"));
});
});
I tried also Error() and some other variants and just can't figure out how to make it work.
Видео javascript - How can I write a test which expects an 'Error' to be thrown in Jasmine? канала Code Samples
In my Node.js module I have the following code:
throw new Error("Parsing is not possible");
Now I try to write a test which expects this error:
describe('my suite...', function() {
[..]
it('should not parse foo', function() {
[..]
expect(parser.parse(raw)).toThrow(new Error("Parsing is not possible"));
});
});
I tried also Error() and some other variants and just can't figure out how to make it work.
Видео javascript - How can I write a test which expects an 'Error' to be thrown in Jasmine? канала Code Samples
Комментарии отсутствуют
Информация о видео
5 апреля 2024 г. 13:22:00
00:00:53
Другие видео канала