Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Nix Test

Nix Test is a declarative testing framework for user-facing behavior in Nix. Tests define the environment, interactions, and expectations together, then run as regular flake checks.

Use Nix Test to exercise:

  • terminal applications through a real pseudo-terminal
  • NixOS services and machines through the NixOS test driver
  • files, users, containers, networks, and HTTP endpoints
  • browser and desktop behavior
  • custom fixtures and matchers with typed locators
{ pkgs, expect, ... }:
{
  test."shows a greeting" = { terminal }: [
    (terminal.open pkgs.hello)
    (expect (terminal.getByText "Hello")).toBeVisible
  ];
}

Start with Getting Started, learn the test model in Writing Tests, or browse the API Reference.