om-smart-test

Runs only Jest and Playwright tests affected by changed code in a monorepo.

1.7k|382|Updated Sep 10, 2025
One-click install
npx skills add https://github.com/open-mercato/open-mercato --skill om-smart-test
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: om-smart-test
Source: https://github.com/open-mercato/open-mercato/tree/main/.ai/skills/om-smart-test
Command: npx skills add https://github.com/open-mercato/open-mercato --skill om-smart-test

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Running the full test suite on every change wastes time in large monorepos. This Skill analyzes your git diff, classifies the scope and layer of changes, and runs only the Jest unit tests and Playwright integration specs that actually cover the modified code.

Core Features & Use Cases

  • Selective Jest execution: Uses --findRelatedTests to traverse the import graph and run only unit tests related to changed source files.
  • Module-aware Playwright mapping: A Python script reads meta.ts dependency declarations in __integration__/ directories to map changed modules to affected integration specs, with layer-aware filtering that skips Playwright for pure CSS or design-token changes.
  • Plan caching: Persists analysis results to .test-cache.json keyed by commit hash, so repeated runs on an unchanged tree skip straight to execution.
  • Use Case: After editing a command handler in the sales module, ask to run affected tests and get only the related Jest suites plus the Playwright specs for sales and its dependent modules, instead of all ~808 test files.

Quick Start

Ask the assistant to run only the tests affected by my current changes on this branch.

Frequently Asked Questions about om-smart-test

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

FAQPage Schema
How do I run only the tests affected by my code changes?

Invoke the smart test workflow, which builds a changed-file list from git diff against the resolved base ref, then runs Jest with --findRelatedTests for unit tests and maps changed modules to Playwright spec files. Results are cached per commit for repeated runs.

How does Jest findRelatedTests select which unit tests to run?

Jest's --findRelatedTests flag traverses the import graph starting from the changed source files and discovers every test file that directly or transitively imports them. Test files themselves are excluded from the input list before invocation.

When are Playwright integration tests skipped for a change?

Playwright is skipped only when all changed files are pure UI layer: CSS files, design tokens, or primitives under packages/ui/src/primitives and packages/ui/src/styles. Any component, API-logic, or data-layer change triggers integration tests because they can affect rendered pages.

What triggers running the full test suite instead of selective tests?

Wide-scope changes force the full suite: modifications under packages/shared, packages/events, packages/queue, packages/cache, shared backend UI components, or root configs like jest.config, tsconfig, package.json, and turbo.json.

Why is my cached test plan ignored after a rebase?

The cache is invalidated when the stored commit hash is no longer reachable from HEAD, which happens after rebases, amends, or force-pushes. The check uses git merge-base --is-ancestor rather than object existence, so dangling commits correctly invalidate the cache.

How do integration tests declare cross-module dependencies?

Each __integration__ directory contains a meta.ts or index.ts file exporting dependsOnModules, requiredModules, or requiresModules arrays. The mapping script reads these declarations so a change in one module also runs specs of modules that depend on it.