testing-principles

Guide black box UI and integration testing with semantic selectors.

9|Updated Jan 18, 2025
One-click install
npx skills add https://github.com/TheNordicOne/ngx-formbar --skill testing-principles-thenordicone
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-principles
Source: https://github.com/TheNordicOne/ngx-formbar/tree/main/.claude/skills/testing-principles
Command: npx skills add https://github.com/TheNordicOne/ngx-formbar --skill testing-principles-thenordicone

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps you avoid brittle tests and weak coverage by enforcing a consistent black-box testing philosophy, selector hierarchy, and mocking rules that keep tests aligned with real user behavior.

Core Features & Use Cases

  • Black box testing: assert on user-observable behavior instead of internal implementation details
  • Semantic selector hierarchy: prefer accessibility-driven queries like role and label before falling back to placeholders, text, scoping, and finally data-testid
  • Mocking and async guidance: mock only system boundaries and use proper async patterns for reliable assertions in reactive UI flows

Quick Start

Activate this skill while writing or reviewing any test file (for example a *.spec.ts) to ensure your queries, assertions, and mocks follow the same stable, accessibility-first rules.

Frequently Asked Questions about testing-principles

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write resilient component tests that don't break on UI changes?

Black box testing for UI uses a semantic selector hierarchy, preferring accessibility-driven queries like role and label before falling back to text or data-testid. This prevents brittle tests by asserting user-observable behavior instead of internal implementation details.

Why are my unit tests failing intermittently in Angular reactive flows?

Intermittent unit test failures in reactive flows often stem from improper async assertion patterns. Applying correct async testing guidance ensures assertions wait for stable state, while disciplined mocking of system boundaries prevents race conditions and timing issues.

What is the best way to mock dependencies in integration tests?

The best way to mock dependencies in integration tests is boundary-focused mocking, which intercepts only external system boundaries. This black-box approach forbids mocking internal modules, ensuring tests validate real integration behavior and remain maintainable.

Do I need data-testid attributes for all my component tests?

You do not need data-testid attributes for all component tests. Semantic selectors provide a precedence order where accessibility queries like role and label are preferred, using data-testid only as a final fallback to maintain accessibility coupling.

When should I avoid black-box testing for UI behavior?

You should avoid black-box testing for UI behavior when you need to assert on specific internal implementation details or deep stylistic CSS selectors. This approach forbids DOM scans, making it unsuitable for tests requiring precise internal structural validation.