From the course: Angular: Testing and Debugging
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Solution: Custom test bed wrapper - Angular Tutorial
From the course: Angular: Testing and Debugging
Solution: Custom test bed wrapper
(upbeat music) - Okay. Here's my solution for the challenge. Keep in mind that my solution and your solution may be different, and that's okay. I made a class called CustomTestBed using the same ng generate commands we've used in previous videos. This class implements Angular's TestBed has a partial. Partial is a utility type introduced in recent versions of TypeScript. It returns a version of whatever type you pass in with all its properties set as optional. It's a great tool for things like this, because we get all the benefits of type safety without needing to implement all of TestBed's properties. Next, I made my own version of configureTestingModule. It has an object full of default values for the testing module config. This is where we store things like the WebStorageService which we want to inject into all our tests. I then return a copy of Angular's TestBed, calling configureTestingModule, and passing in a modified configure object. I use object data sign to merge the default…
Contents
-
-
-
-
-
-
-
(Locked)
Testing overview2m 26s
-
(Locked)
Basic Karma configuration3m 35s
-
Testing services5m 22s
-
(Locked)
Fixing injection dependency errors6m 1s
-
(Locked)
Testing pipes4m 29s
-
(Locked)
Testing components6m 27s
-
(Locked)
Challenge: Custom test bed wrapper22s
-
(Locked)
Solution: Custom test bed wrapper1m 53s
-
(Locked)
-
-
-