Loading topic
ng test command runs your specs with Vitest. It assumes you know basic TypeScript, Angular standalone components and dependency injection, and signals with input() and output(). It also assumes you can use npm and the Angular CLI. By the end you will be able t5 min readng test with the Vitest runner, which the setup chapter covers. It also assumes you know basic TypeScript and Angular standalone components. Here you will learn how a Vitest test file is built, what the matchers do, and which mistakes cause most confusing failures.5 min readTestBed builds a component for a test. It assumes you can write a basic Vitest test with describe, it, and expect, and that you know standalone components, inject(), and signal inputs. You also need to be able to run ng test.4 min readTestBed.createComponent, and read Angular signals in templates. It covers what a ComponentFixture gives you and when the DOM updates in a test.5 min readTestBed and fixtures. You should be able to create a component with TestBed.createComponent, call fixture.detectChanges(), and write describe, it, and expect blocks. Here you learn how to find elements in the rendered output, how to act 5 min readsetInput, read outputs by subscribing to them, and check both the rendered DOM and the emitted values. It assumes you can already create a component with TestBed, call fixture.detectChanges(), and5 min readfixture.detectChanges() works, and understand Angular dependency injection with inject() and providers. It covers how to swap real services for test doubles. It uses vi.fn, vi.spyOn, and the providers array.6 min readHttpTestingController. It replaces the network layer, so your test can see each request, answer it with data of your choosing, and check that nothing unexpected was sent. This c4 min readTestBed, and that you know how to read a ComponentFixture and call detectChanges(). You should also be comfortable with `vi.fn()4 min readTestBed, ComponentFixture, and DOM queries, as covered in the earlier chapters. It adds a second way to drive a component: a harness. A harness is a class that wraps a component's DOM and exposes the actions a user takes, such as clicking or4 min readTestBed test, set inputs with setInput, read outputs, and replace a service with a provider. Here the question is which tests are worth writing, not how to write them. A suite with too many implementation-bound tests slows you down on every refactor. 5 min readng test, as covered in the earlier chapters. It shows how to measure which code your tests run, and how to run the suite automatically on every push so broken tests never reach the main branch.6 min readng test, write a TestBed test, and read the test target in angular.json. It covers why you might move your Vitest tests out of the default simulated DOM and into a real browser, how to do that with the Angular CLI, and what changes.5 min read