@marginallyuseful/soll-vitest
v0.0.1-c591f86e
Published
Vitest integration for soll — scopes test runs to affected files
Downloads
3,509
Readme
@soll/vitest
Vitest integration for soll — scope test runs to only affected files.
Prerequisites: Install soll and run soll diagnose --write in your project first.
Quick start
Install and configure the custom sequencer in your Vitest config:
npm install --save-dev @soll/vitest// vitest.config.ts
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
sequence: {
sequencer: "@soll/vitest/sequencer",
},
},
});That's it. When you run vitest, soll filters the test list to only tests affected by your changes.
How it works
The custom sequencer hooks into Vitest's sequence.sequencer option. It builds the import graph once, computes the affected set from git merge-base diff against the default branch, then filters the test list to only affected files. Non-affected tests are skipped entirely.
If the native addon or git isn't available, it falls back to running all tests.
Running all tests
To bypass soll filtering and run every test:
vitest --changed falseProgrammatic API
For custom integrations:
import { getAffectedTests } from "@soll/vitest";
const result = getAffectedTests({
root: process.cwd(),
include: await glob("**/*.ts"),
changedFiles: ["src/logger.ts"],
tests: ["src/logger.test.ts", "src/app.test.ts"],
});
// result.affectedTestFiles -> ["src/logger.test.ts"]Exports
| Specifier | Description |
| ------------------------ | ------------------------------------- |
| @soll/vitest | Programmatic API (getAffectedTests) |
| @soll/vitest/sequencer | Custom sequencer class |
Development
bun install
bun run --filter @marginallyuseful/soll-vitest build
bun run --filter @marginallyuseful/soll-vitest typecheck