testing-guidelines

A set of testing instructions for Angular libraries in Fundamental NGX, a collection of reusable Angular components and utilities. It explains how to run tests, write tests around user behaviour, and check common testing concerns.

In plain words
What is it for?
It is for running all, selected, affected, or watch-mode tests; testing components, user interactions, dependency injection, and asynchronous code; and linting test files.
Why use it?
It gives developers a consistent way to test Angular code and helps avoid mistakes such as checking only implementation details or missing accessibility and asynchronous behaviour.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/sap/fundamental-ngx/testing-guidelines
Clone the repo
git clone --depth 1 https://github.com/SAP/fundamental-ngx
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,408 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.02408
Opus 5 $0.00000 $0.01204
Sonnet 5 $0.00000 $0.00482
Haiku 4.5 $0.00000 $0.00241

Measured yesterday against content hash ccf35236f0d3, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

testing-guidelines scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/agents/testing-guidelines.md · 427 lines

How it starts

The opening of the file, as written. The whole thing — 427 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Testing Guidelines

This document covers testing patterns and best practices for Angular 22+ development in Fundamental NGX.

Table of Contents


Test Commands

# Run all tests in a library
nx test <library>

# Run specific test file
nx run <library>:test --testfile=<filename>.spec.ts

# Examples
nx run cdk:test --testfile=line-clamp.directive.spec.ts
nx run core:test --testfile=button.component.spec.ts
nx run platform:test --testfile=table.component.spec.ts

# Watch mode (recommended during development)
nx test <library> --watch

# Run affected tests only
nx affected:test

# Lint specific library
nx run <library>:lint

Test Writing Guidelines

Focus on User Scenarios, Not Edge Cases

When writing tests, ask: "Can this actually happen in a real Angular application?"

✅ Write tests for

  • User interactions (clicks, inputs, keyboard)
  • Valid configuration options
  • Component lifecycle (mount, update, unmount)
  • Accessibility requirements
  • Realistic error scenarios (unsupported enum values, optional services missing)

❌ Don't write tests for

  • TypeScript-prevented scenarios (undefined for required parameters)
  • Angular DI-prevented scenarios (missing required dependencies)
  • Implementation details (internal signal updates, private methods)
  • Impossible states (null values in non-nullable fields)

Example: Realistic vs Unrealistic Tests

// ✅ GOOD - Tests realistic user scenario
it('should fallback to cozy when unsupported density is provided', () => {
    const observer = new ContentDensityObserver(injector, {
        supportedContentDensity: [ContentDensityMode.COZY],
        defaultContentDensity: ContentDensityMode.COMPACT // User might try this
    });
    expect(observer.value).toBe(ContentDensityMode.COZY); // Fallback works
});

// ❌ BAD - Tests impossible scenario (TypeScript prevents this)
it('should handle undefined defaultContentDensity', () => {
    const observer = new ContentDensityObserver(injector, {
        defaultContentDensity: undefined // TypeScript won't allow this!
    });
    expect(observer.value).toBe(ContentDensityMode.COZY);
});

Read the full file on GitHub · 427 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 427 lines · 0 tokens per session scan A ccf35236f0d3

Subscribe to this mod's changes

testing-guidelines is an agent published in the GitHub repository SAP/fundamental-ngx (294 stars, last pushed yesterday), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 2,408 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.