Speed up your monorepo pipeline by only running the tests affected by your code diff.
- TypeScript support, including path aliases
- Configurable resolver, with support for extensions, export conditions and more
- High performance because it is written in Rust using Oxc
- Easy to use with Node API
yarn add sovra
Returns a subset of testFiles
that have changedFiles
in their import graph. This is useful in order to determine which tests to run in a large repo.
Name | Description |
---|---|
testFiles |
List of files to check if they were affected by changes |
changedFiles |
List of changed files |
resolverOptions |
Configuration on how to resolve imports, see oxc-resolver |
import { getAffected } from "sovra";
import { execSync } from "node:child_process";
import { glob } from "glob";
const testFiles = glob.sync("src/**/*.spec.{ts,tsx}");
const changedFiles = execSync("git diff --name-only main", { encoding: "utf8" })
.trim()
.split("\n");
const resolverOptions = {
tsconfig: {
configFile: "tsconfig.json",
},
};
const affected = getAffected(testFiles, changedFiles, resolverOptions);
if (affected.errors) {
console.error(...affected.errors);
} else {
console.log(affected.files);
}
cargo test
Imports using variables or expressions are not supported as they can only be determined during runtime:
require(process.env.SOME_VAR + ".js"); // ❌
import(`./file.${platform}.mjs`); // ❌
MIT © Joel Arvidsson 2024