Skip to content

Tests

To ease testing of your environments, we provide a way to define the tests and to run them.

Writing devenv tests

A simple test would look like:

devenv.nix
{ pkgs, ... }: {
  tests.basic = {
    nix = ''
      { pkgs, ... }: {
        packages = [ pkgs.ncdu ];
      }
    '';
    test = ''
      ncdu --version | grep "ncdu 2.2"
    '';
  };
}
$ devenv test
✔ Gathering tests in 0.3s.
• Found 1 test(s), running 1:
•   Testing basic ...
•     Running $ devenv ci
•     Running .test.sh.
✔   Running basic in 16.7s.

Defining tests in a folder

A simple test with a test script:

$ ls tests/mytest/
.test.sh devenv.nix devenv.yaml

Define tests:

devenv.nix
{ config, ... }: {
  tests = config.lib.mkTests ./tests;
}

Run tests:

$ devenv test
...