Skip to content

Configuration

Unrift works with zero configuration. When you need to customize behavior, create a config file in your project root.

Create unrift.config.ts:

import { defineConfig } from "unrift";
export default defineConfig({
testDir: "test",
timeoutMs: 5000,
bail: false,
includes: ["**/*.spec.ts"],
excludes: ["**/fixtures/**"],
});

Unrift searches upward from your project root for a config file named unrift.config.* with any of these extensions: .ts, .js, .mjs, .cjs, .json.

OptionTypeDefaultDescription
testDirstring"test"Directory to search for test files (relative to config file)
timeoutMsnumber-Default timeout for each test in milliseconds
bailbooleanfalseStop running tests after the first failure
patternstring-Regex pattern to filter test files by path
includesstring[]-Glob or regex patterns - only matching files are included
excludesstring[]-Glob or regex patterns - matching files are excluded
matchersstring[]-Module specifiers for custom matcher packages

Unrift recursively scans testDir for files matching these patterns:

  • *.spec.ts / *.test.ts
  • *.spec.js / *.test.js
  • *.spec.mts / *.test.mts
  • *.spec.cts / *.test.cts
  • *.spec.tsx / *.test.tsx
  • *.spec.jsx / *.test.jsx
  • *.spec.mjs / *.test.mjs
  • *.spec.cjs / *.test.cjs

Both includes and excludes accept glob patterns or regex strings. Patterns containing *, ?, [, or { are treated as globs; everything else is treated as a raw regex for backward compatibility.

export default defineConfig({
testDir: "test",
includes: ["**/*.spec.ts"], // glob - only .spec.ts files
excludes: ["**/fixtures/**", "e2e/**"], // glob - skip these directories
});

Regex strings still work if you need them:

export default defineConfig({
excludes: ["\\.fixture\\.ts$"], // regex - exclude .fixture.ts files
});

Register matcher packages that are loaded before tests run:

export default defineConfig({
matchers: ["my-custom-matchers"],
});

The module should call expect.extend() when imported.

CLI flags override config file values:

Terminal window
unrift --bail --timeout 10000 --config ./custom.config.ts

See the CLI reference for all flags.