Angular + Vitest
Vite-native test runner, with a sample counter component test. This page shows exactly what pickstack adds to a Angular project for Vitest: 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 vitest --yesCustomize in the configurator
Packages it adds
| Package | Version | Type |
|---|---|---|
jsdom | ^31.0.1 | dev |
vitest | ^5.1.1 | dev |
New files
import { TestBed } from "@angular/core/testing";
import { Counter } from "./counter";
describe("Counter", () => {
it("increments when +1 is clicked", async () => {
const fixture = TestBed.createComponent(Counter);
await fixture.whenStable();
const element = fixture.nativeElement as HTMLElement;
const plus = [...element.querySelectorAll("button")].find(
(b) => b.textContent?.trim() === "+1",
);
plus?.click();
await fixture.whenStable();
expect(element.querySelector("p")?.textContent?.trim()).toBe("1");
});
});
{
"extends": "./tsconfig.json",
"compilerOptions": {
"types": ["vitest/globals"]
},
"include": ["src/**/*.d.ts", "src/**/*.spec.ts"]
}
Changes to existing files
⋯ 61 unchanged lines } }, "defaultConfiguration": "development"+ },+ "test": {+ "builder": "@angular/build:unit-test" } } }⋯ 3 unchanged lines
<section class="page"> <h1 class="title">About</h1>+ <p class="text">Built with Angular 22, TypeScript, Vitest.</p>− <p class="text">Built with Angular 22, TypeScript.</p> </section>
⋯ 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.csstsconfig.app.jsontsconfig.jsontsconfig.spec.json