pickstack

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 --yes
Customize in the configurator

Packages it adds

PackageVersionType
@testing-library/angular^19.6.0dev
@testing-library/dom^10.4.2dev
@testing-library/jest-dom^8.0.0dev
@testing-library/user-event^14.6.13dev
jsdom^31.0.1dev
vitest^5.1.1dev

New files

src/app/components/counter/counter.spec.ts
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();
  });
});
src/test-setup.ts
import "@testing-library/jest-dom/vitest";
tsconfig.spec.json
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "types": ["vitest/globals"]
  },
  "include": ["src/**/*.d.ts", "src/**/*.spec.ts", "src/test-setup.ts"]
}

Changes to existing files

angular.json (changed)
⋯ 61 unchanged lines             }           },           "defaultConfiguration": "development"+        },+        "test": {+          "builder": "@angular/build:unit-test",+          "options": {+            "setupFiles": ["src/test-setup.ts"]+          }         }       }     }⋯ 3 unchanged lines
src/app/pages/about/about.html (changed)
 <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>  
tsconfig.app.json (changed)
⋯ 3 unchanged lines     "types": []   },   "include": ["src/**/*.ts"],+  "exclude": ["src/**/*.spec.ts", "src/test-setup.ts"]−  "exclude": ["src/**/*.spec.ts"] }  
tsconfig.json (changed)
⋯ 22 unchanged lines   "references": [     {       "path": "./tsconfig.app.json"+    },+    {+      "path": "./tsconfig.spec.json"     }   ] }⋯ 1 unchanged lines

Project files

Related templates