Angular + Testing Library
Test like a user: render, screen, user-event and jest-dom. This page shows exactly what pickstack adds to a Angular project for Testing Library: the packages, the new files and the changes to existing ones. Every combination is installed, built, linted and tested in CI.
$ npm create pickstack@latest my-app -- --framework angular --modules testing-library --yesCustomize in the configurator
Packages it adds
| Package | Version | Type |
|---|---|---|
@testing-library/angular | ^19.6.0 | dev |
@testing-library/dom | ^10.4.2 | dev |
@testing-library/jest-dom | ^8.0.0 | dev |
@testing-library/user-event | ^14.6.13 | dev |
jsdom | ^31.0.1 | dev |
vitest | ^5.1.1 | dev |
New files
import { render, screen } from "@testing-library/angular";
import userEvent from "@testing-library/user-event";
import { Counter } from "./counter";
describe("Counter", () => {
it("increments when +1 is clicked", async () => {
const user = userEvent.setup();
await render(Counter);
await user.click(screen.getByRole("button", { name: "+1" }));
expect(screen.getByText("1")).toBeInTheDocument();
});
});
import "@testing-library/jest-dom/vitest";
{
"extends": "./tsconfig.json",
"compilerOptions": {
"types": ["vitest/globals"]
},
"include": ["src/**/*.d.ts", "src/**/*.spec.ts", "src/test-setup.ts"]
}
Changes to existing files
⋯ 61 unchanged lines } }, "defaultConfiguration": "development"+ },+ "test": {+ "builder": "@angular/build:unit-test",+ "options": {+ "setupFiles": ["src/test-setup.ts"]+ } } } }⋯ 3 unchanged lines
<section class="page"> <h1 class="title">About</h1>+ <p class="text">+ Built with Angular 22, TypeScript, Vitest, Testing Library.+ </p>− <p class="text">Built with Angular 22, TypeScript.</p> </section>
⋯ 3 unchanged lines "types": [] }, "include": ["src/**/*.ts"],+ "exclude": ["src/**/*.spec.ts", "src/test-setup.ts"]− "exclude": ["src/**/*.spec.ts"] }
⋯ 22 unchanged lines "references": [ { "path": "./tsconfig.app.json"+ },+ {+ "path": "./tsconfig.spec.json" } ] }⋯ 1 unchanged lines
Project files
.gitignoreREADME.mdangular.jsonpackage.jsonpublic/robots.txtsrc/app/app.config.tssrc/app/app.htmlsrc/app/app.routes.tssrc/app/app.tssrc/app/components/counter/counter.htmlsrc/app/components/counter/counter.spec.tssrc/app/components/counter/counter.tssrc/app/pages/about/about.htmlsrc/app/pages/about/about.tssrc/app/pages/home/home.htmlsrc/app/pages/home/home.tssrc/index.htmlsrc/main.tssrc/styles.csssrc/test-setup.tstsconfig.app.jsontsconfig.jsontsconfig.spec.json