cui-javascript-unit-testing

Configure Jest unit tests for CUI JavaScript projects with 80% coverage.

1|Updated Feb 3, 2025
One-click install
npx skills add https://github.com/cuioss/cui-llm-rules --skill cui-javascript-unit-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cui-javascript-unit-testing
Source: https://github.com/cuioss/cui-llm-rules/tree/main/claude/marketplace/bundles/cui-frontend-expert/skills/cui-javascript-unit-testing
Command: npx skills add https://github.com/cuioss/cui-llm-rules --skill cui-javascript-unit-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill codifies Jest-based unit testing standards for React/Lit-like components, focusing on AAA patterns, mocks, and 80%+ coverage.

Core Features & Use Cases

  • Jest Configuration: Environment, module mapping, transforms, setup files.
  • Test Structure: Standard directory layout, naming, and setup patterns.
  • Patterns & Mocking: Component testing patterns and mocking strategies.
  • Coverage: 80% minimum coverage across branches, functions, lines, and statements.

Quick Start

Create unit tests following the patterns and run coverage to ensure quality gates are met.

Frequently Asked Questions about cui-javascript-unit-testing

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

FAQPage Schema
How do I set up Jest unit testing standards for JavaScript projects?

Jest unit testing standards define configuration for jsdom environment, babel-jest transforms, moduleNameMapper mocks for Lit and DevUI, and testMatch patterns. This ensures consistent test structure, proper mocking strategies, and 80% minimum coverage across branches, functions, lines, and statements in CI pipelines.

What's the best way to structure Jest tests and organize test files?

Standard Jest test structure uses testMatch patterns to locate tests, AAA (Arrange-Act-Assert) patterns for test logic, setupFiles for initialization, and consistent directory layouts. This approach keeps tests maintainable, discoverable, and aligned with project conventions.

How do I mock dependencies and external libraries in Jest?

Jest mocking strategies use moduleNameMapper to mock framework libraries like Lit and DevUI, and babel-jest for code transformation. These techniques isolate component tests from external dependencies, enabling faster test execution and predictable behavior.

What coverage thresholds and reporting formats does Jest support?

Jest coverage management enforces an 80% global threshold across branches, functions, lines, and statements, with reports generated in text, lcov, html, and cobertura formats. This enables quality gates in CI pipelines and visibility into test coverage gaps.

When should I apply mocking versus integration testing in Jest?

Mocking is appropriate for unit tests isolating components and their immediate dependencies; integration testing combines multiple modules. Jest's mocking patterns focus on unit-level testing with controlled inputs, while integration tests validate end-to-end workflows across the stack.

Can I use Jest with React and Lit-like components?

Jest supports React and Lit-like component testing through jsdom testEnvironment, babel-jest transforms, and moduleNameMapper configuration for framework-specific mocks. This enables standardized unit testing across component libraries.