Skip to content

Content Tagged "tothrow"

Page 1 of 1

Use "toThrowError" and "toThrow" in TypeScript with Objects

March 2, 2017Category: Software
TL;DR: wrap your method call in the expect() statement. Instead of expect(obj.method()).toThrow() , write expect( () => { obj.method() }).toThrow() . While in the process of improving the code coverage, I needed to write a test for a method throwing an exception. My initial code would have been…

All tags