Index of every page on this site: llms.txt
All skills
marmicode avatar

/angular-testing

@fa09f8d
by marmicodemarmicode/skills17 stars
Run it yourself

Writes, fixes and reviews Angular tests following the Pragmatic Angular Testing approach — fakes over mocks, real collaborators by default, components tested through the DOM rather than through fixtures. Targets Vitest (Browser Mode preferred, jsdom and happy-dom supported) and also applies to Jest, Jasmine/Karma and Angular Testing Library projects, including migrating them to Vitest. Use whenever adding, editing, reviewing or debugging unit tests in an Angular project — *.spec.ts files, TestBed, components, services (`@Service` or `@Injectable`), signals, guards, routing, and timers — including when tests are written as part of a feature or bug fix, when replacing mocks or spies with fakes, when declaring or faking a service, and when fixing slow or flaky tests. Prefer this over general Angular skills for anything test-related. Not for Playwright or Cypress end-to-end tests.

Use this Skill: https://skilld.dev/gh/marmicode/skills/angular-testing

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesrunning-tests.md

≈628 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Running Tests

Run only the spec you touched, through the project's own test target. Find it first: the test script in package.json, the test target in angular.json or project.json, or a Vitest config.

If a Wallaby skill is available, follow it instead of the commands below. If Wallaby is installed (a Wallaby config, or @wallabyjs in the project) and no Wallaby skill is available, suggest that the user install it.

Contents

  1. Vitest CLI
  2. Angular CLI
  3. Nx

Vitest CLI

npx vitest run path/to/x.spec.ts
  • The path is a filter: Vitest runs the test files whose path contains it. vitest run runs once, without watch mode.
  • Vitest looks for its config in the root only, which is --root or the current working directory. It does not pick the config closest to the file. In a monorepo, run the command from the directory that holds the config, or pass --root <dir> or --config <path>.
  • When the config declares several projects, add --project <name> (e.g. --project browser) to run only that project.
  • There is no --include or --testFiles flag.

Angular CLI

Use this only when angular.json runs tests with the @angular/build:unit-test builder. An Angular project may run Vitest directly, with no test runner in angular.json — use the Vitest CLI then.

ng test <project> --include path/to/x.spec.ts --no-watch
  • --include takes glob patterns relative to the project source root. A file path includes that test file; a directory path includes every test file in it.
  • <project> is the Angular project name. Vitest's --project flag does not apply here.
  • --filter <regex> narrows down to matching suite and test names.

Nx

Check the executor of the test target first: the option differs.

Target Command
@nx/vitest:test executor nx test <project> --testFiles=path/to/x.spec.ts
@angular/build:unit-test executor nx test <project> --include path/to/x.spec.ts
Inferred target running the vitest command nx test <project> -- x.spec.ts (a Vitest filter)

An inferred target runs Vitest from the project directory, so a workspace-relative path may not match. Use the file name or a path relative to the project.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts11d3 checks · Risk SAFE
  • Gen Agent Trust Hub11d

    The skill provides comprehensive guidelines and examples for writing Angular tests using Vitest and other industry-standard tools. It promotes testing best practices like using fakes and browser-mode integration testing. No malicious patterns, obfuscation, or security risks were identified.

  • Socket11d

    No alerts

  • Snyk11d

    Risk: LOW · No issues

Signed by skilld at fa09f8d. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 2 weeks ago

README badge

README badge for marmicode/skills/angular-testing