@marginallyuseful/soll-jest
v0.0.1-05b9ce9b
Published
Jest integration for soll — scope test runs to affected files
Readme
@soll/jest
Jest integration for soll — scope test runs to only the files affected by a set of changed files.
Prerequisites: Install soll and run soll diagnose --write in your project first.
Quick start (preset)
The easiest way to use @soll/jest is via the preset. Install it and add a single line to your Jest config:
npm install --save-dev @soll/jest// jest.config.json
{
"preset": "@soll/jest"
}That's it. Jest will automatically:
- Read
tsconfig.jsonto discover source files - Compute changed files via
git merge-basediff against the default branch - Filter test runs to only affected tests
- In watch mode, re-filter on each file change
Architecture
Sits in the packages/ layer of the soll workspace. Consumes the native addon produced by crates/napi/ (via require) and exposes a pure-TypeScript API that returns Jest-compatible filter patterns (--testPathPattern, --testNamePattern).
packages/jest/
src/
index.ts # public API: SollConfig → AffectedTestResult
file-granularity.ts # file-level scoping (pattern building, result shaping)
git.ts # git merge-base diff helpers
discovery.ts # tsconfig-based source file discovery
sequencer.ts # custom TestSequencer (filters to affected files)
watch-plugin.ts # watch mode plugin (shouldRunTestSuite hook)
jest-preset.ts # preset config wiring sequencer + watch plugin
__tests__/ # unit tests for each module
jest-preset.js # root-level preset entry pointPreset components
| Component | What it does |
| ------------------------------------ | -------------------------------------------------------------------------------- |
| Sequencer (sequencer.ts) | Extends @jest/test-sequencer to filter sort() results to affected test files |
| Watch plugin (watch-plugin.ts) | Implements shouldRunTestSuite hook; caches affected set per run |
| Preset (jest-preset.ts) | Wires sequencer + watch plugin into Jest config |
Running all tests
To bypass soll filtering and run every test:
jest --all # disables sequencer filtering
jest --watchAll # disables watch plugin filteringProgrammatic API
For custom integrations that need more control than the preset provides:
import { getAffectedTests } from "@soll/jest";
const result = getAffectedTests({
root: process.cwd(),
include: await glob("**/*.ts"),
changedFiles: ["src/logger.ts"],
});
// Pass to Jest:
// jest --testPathPattern <result.testPathPattern>Exports
| Specifier | Description |
| ------------------------- | ------------------------------------- |
| @soll/jest | Programmatic API (getAffectedTests) |
| @soll/jest/sequencer | Custom TestSequencer class |
| @soll/jest/watch-plugin | Watch mode plugin |
| @soll/jest/jest-preset | Preset configuration object |
Development
pnpm install # install dependencies
pnpm build # compile TypeScript
pnpm test # run unit tests
pnpm typecheck # type-check without emitting