Laur's blog
Sign in Subscribe

karma

A collection of 2 posts
Use "toThrowError" and "toThrow" in TypeScript with Objects
jasmine

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

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 something
Mar 2, 2017 1 min read
Fix Angular 2 Tests with Karma
2

Fix Angular 2 Tests with Karma

Below are some fixes I had to apply in order to make Angular 2 tests work with karma. Binding * Error: Can't bind to 'ngModel' since it isn't a known property of 'input' * Solution: Import FormsModulein your test: TestBed.configureTestingModule({ declarations: [AppComponent], imports:
Mar 1, 2017 1 min read
Page 1 of 1
Laur's blog © 2025
  • Sign up
Powered by Ghost