Skip to content

Migrating from Jest

Unrift’s API is designed to be familiar to Jest and Vitest users. Most tests can be migrated with minimal changes.

These work identically in Unrift:

  • describe(), it(), test()
  • expect() with .toBe(), .toEqual(), .toThrow(), etc.
  • .not chaining
  • beforeAll, afterAll, beforeEach, afterEach
  • .only, .skip
  • Async test functions

The main difference is explicit imports. Unrift doesn’t inject globals:

// Jest: globals are available automatically
describe("math", () => {
import { describe, it, expect } from "unrift";
describe("math", () => {
it("adds", () => {
expect(1 + 1).toBe(2);
});
});
jest.config.ts
export default {
testMatch: ["**/*.spec.ts"],
transform: { "^.+\\.tsx?$": "ts-jest" },
};
// unrift.config.ts
import { defineConfig } from "unrift";
export default defineConfig({
testDir: "test",
includes: ["\\.spec\\.ts$"],
});
JestUnriftNotes
jestunriftRun all tests
jest --bailunrift --bailSame flag
jest --jsonunrift --jsonSimilar output
jest mathunrift mathPattern filter
jest --config pathunrift --config pathSame concept
jest --testTimeout 5000unrift --timeout 5000Different flag name

Most matchers are identical. Key differences:

JestUnriftStatus
toBetoBeSame (Object.is)
toEqualtoEqualSame (deep, prototype-insensitive)
toStrictEqualtoStrictEqualSame (deep, prototype-sensitive)
toMatchObjecttoMatchObjectSame (partial recursive match)
toHavePropertytoHavePropertySame (dot-notation and array paths supported)
toMatchSnapshotNot yet supported
toMatchInlineSnapshotNot yet supported
toHaveBeenCalledNo built-in mocking

These Jest features are planned but not yet available:

  • Snapshot testingtoMatchSnapshot, toMatchInlineSnapshot
  • Mockingjest.fn(), jest.mock(), jest.spyOn()
  • Coverage--coverage flag
  • Watch mode--watch flag
  • Parallel execution — tests run sequentially
  • Custom reporters — only built-in pretty and JSON output
  • Browser/DOM environment — Node.js only

For mocking, you can use standalone libraries like tinyspy alongside Unrift.