ende test

Ende ships with a built-in test runner using the Ende.test() API. To learn how to write tests, see the Testing fundamentals guide. For assertions, see @ende/assert and @ende/expect.

Running tests

Run all tests in the current directory and subdirectories:

ende test

Run tests in specific files:

ende test src/fetch_test.ts src/signal_test.ts

Run tests matching a glob pattern:

ende test src/*.test.ts

Skip type-checking:

ende test --no-check

Filtering

Run only the tests whose name matches a string or a pattern with --filter:

# Run tests whose name contains "database"
ende test --filter "database"

# Run tests whose name matches a regular expression
ende test --filter "/^connect.*/"

Wrap the filter value in forward slashes (/) to treat it as a regular expression, like JavaScript's regex literal syntax. Filtering does not affect test steps: when a test's name matches the filter, all of its steps run.

To control which test files are collected in the first place, set test.include and test.exclude in your config file. See include and exclude.

Running affected tests

When iterating on a change, you can run only the tests touched by it instead of the whole suite. These are one-shot runs, not watch mode.

--changed runs the test modules affected by files changed in git. With no value it uses the working tree (staged, unstaged, and untracked files); pass a ref to also include commits since the merge-base with that ref:

# Tests affected by uncommitted changes
ende test --changed

# Tests affected since branching off main
ende test --changed=origin/main

--related runs the test modules that depend on specific source files, without consulting git:

# Tests that import src/util.ts
ende test --related=src/util.ts

Both flags filter the collected test files down to those that reach the changed or named files through the module graph. See Running affected tests in the testing guide for the workflow and how selection works.

Permissions

Tests run with the same permission model as ende run. Grant permissions for your test suite:

ende test --allow-read --allow-net

Watch mode

Re-run tests automatically when files change:

ende test --watch

Parallel execution

Run test files across multiple worker threads:

ende test --parallel

By default, --parallel uses the number of available CPUs. Use ENDE_JOBS=<N> to control the number of threads:

ENDE_JOBS=4 ende test --parallel

Code coverage

Collect coverage data and generate a report:

ende test --coverage

This writes raw coverage data to a coverage/ directory. To generate a summary from existing coverage data, use ende coverage:

ende coverage coverage/

You can also output an lcov report for use with external tools:

ende coverage --lcov coverage/ > coverage.lcov

To fail the run when coverage drops below a target, set a threshold (for example ende coverage --threshold=90). See coverage thresholds for per-metric configuration.

Parameterized tests

Run the same test body over a table of cases with Ende.test.each, which registers one independently reported test per case. See Parameterized tests for the name templates and case forms.

Snapshot testing

Capture a value and compare it against a stored reference on every run with the built-in t.assertSnapshot, updating with --update-snapshots (-u). See Snapshot testing.

Reporters

Choose an output format with --reporter. Four reporters are built in:

  • pretty (default): detailed, human-readable output
  • dot: one character per test, for a concise overview
  • junit: JUnit XML format, for CI systems
  • tap: Test Anything Protocol output
ende test --reporter=dot
ende test --reporter=tap

Write a JUnit XML report to a file while keeping the human-readable pretty output in the terminal:

ende test --junit-path=report.xml

Randomize order

Shuffle the order tests run in to catch hidden dependencies between tests:

ende test --shuffle

Sharding

Split a test suite across several machines with --shard=<index>/<count>, where index is 1-based. The discovered test files are sorted for a stable order and divided into <count> balanced groups; the run executes only the files in group <index>:

# On machine 1 of 3
ende test --shard=1/3

# On machine 2 of 3
ende test --shard=2/3

Sharding is applied before --shuffle, so a given shard runs the same files on every machine regardless of the shuffle seed.

Retrying and repeating

Set a run-wide default for retries and repetitions with --retry and --repeats:

# Re-run each failing test up to twice before reporting failure
ende test --retry=2

# Run every test three times and fail if any run fails
ende test --repeats=3

A test that sets its own retry or repeats option overrides the flag. See retrying and repeating tests for the per-test options.

Leak detection

Trace the source of leaked async operations, timers, or resources:

ende test --trace-leaks

Testing code in documentation

Evaluate code blocks in JSDoc and Markdown files as tests:

ende test --doc

See documentation tests for details.

Command line usage:

test

Run tests

Options

--cached-only

Require that remote dependencies are already cached.

--cert

Load certificate authority from PEM encoded file.

--changed

Run only test modules affected by files changed in git. With no value, uses uncommitted changes (staged, unstaged and untracked). Pass a git ref to compare against, e.g. --changed=main or --changed=HEAD~1.

--check

Set type-checking behavior. This subcommand type-checks local modules by default, so passing --check is redundant; pass --check=all to also type-check remote modules. Alternatively, use the 'ende check' subcommand.

--clean

Empty the temporary coverage profile data directory before running tests. Note: running multiple ende test --clean`` calls in series or parallel for the same coverage directory may cause race conditions.

--config, -c

Configure different aspects of ende including TypeScript, linting, and code formatting. Typically the configuration file will be called ende.json or ende.jsonc and automatically detected; in that case this flag is not necessary.

--coverage

Collect coverage profile data into DIR. If DIR is not specified, it uses 'coverage/'. This option can also be set via the ENDE_COVERAGE_DIR environment variable.

--coverage-raw-data-only

Only collect raw coverage data, without generating a report.

--coverage-threshold

Fail if coverage is below this percentage (0-100). Requires --coverage.

--doc

Evaluate code blocks in JSDoc and Markdown.

--env-file

Load environment variables from local file Only the first environment variable with a given key is used. Existing process environment variables are not overwritten, so if variables with the same names already exist in the environment, their values will be preserved. Where multiple declarations for the same environment variable exist in your .env file, the first one encountered is applied. This is determined by the order of the files you pass as arguments.

--ext

Set content type of the supplied file.

--fail-fast

Stop after N errors. Defaults to stopping after first failure.

--filter

Run tests with this string or regexp pattern in the test name.

--frozen-lockfile

Error out if lockfile is out of date.

--hide-stacktraces

Hide stack traces for errors in failure test results.

--ignore

Ignore files.

--import-map

Load import map file from local file or remote URL.

--inspect

Activate inspector on host:port [default: 127.0.0.1:9229]. Host and port are optional. Using port 0 will assign a random free port.

--inspect-brk

Activate inspector on host:port, wait for debugger to connect and break at the start of user script.

--inspect-publish-uid

--inspect-wait

Activate inspector on host:port and wait for debugger to connect before running user code.

--junit-path

Write a JUnit XML test report to PATH. Use '-' to write to stdout which is the default when PATH is not provided.

--location

Value of globalThis.location used by some web APIs.

--lock

Check the specified lock file. (If value is not provided, defaults to "./ende.lock").

--min-dep-age

(Unstable) The age in minutes, ISO-8601 duration or RFC3339 absolute timestamp (e.g. '120' for two hours, 'P2D' for two days, '2025-09-16' for cutoff date, '2025-09-16T12:00:00+00:00' for cutoff time, '0' to disable).

--no-check

Skip type-checking. If the value of "remote" is supplied, diagnostic errors from remote modules will be ignored.

--no-clear-screen

Do not clear terminal screen when under watch mode.

--no-config

Disable automatic loading of the configuration file.

--no-lock

Disable auto discovery of the lock file.

--no-remote

Do not resolve remote modules.

--no-run

Cache test modules, but don't run tests.

--parallel

Run test modules in parallel. Parallelism defaults to the number of available CPUs or the value of the ENDE_JOBS environment variable.

--permit-no-files

Don't return an error code if no files were found.

--preload

A list of files that will be executed before the main module.

--reload, -r

Reload source code cache (recompile TypeScript). With no value, reloads everything. Pass a comma-separated list of specifiers to reload only those modules; jsr:@ende/http/file-server,jsr:@ende/assert/equals reloads specific modules.

--repeats

Run each test NUMBER additional times. Every repetition must pass. Tests that set their own repeats option take precedence.

--reporter

Select reporter to use. Default to 'pretty'.

--retry

Re-run failing tests up to NUMBER times. A test passes if any attempt passes. Tests that set their own retry option take precedence.

--sanitize-ops

Enable the ops sanitizer, which ensures that all async ops started in a test are completed before the test ends.

--sanitize-resources

Enable the resources sanitizer, which ensures that all resources opened in a test are closed before the test ends.

--seed

Set the random number generator seed.

--shard

Run only the test files for shard INDEX of COUNT, e.g. --shard=2/3. The discovered test files are sorted and split into COUNT consecutive groups; INDEX is 1-based. Useful for splitting a run across machines.

--shuffle

Shuffle the order in which the tests are run.

--unsafely-ignore-certificate-errors

DANGER: Disables verification of TLS certificates.

--update-snapshots, -u

Update snapshots created with t.assertSnapshot() instead of failing when they do not match.

--v8-flags

To see a list of all available flags use --v8-flags=--help Flags can also be set via the ENDE_V8_FLAGS environment variable. Any flags set with this flag are appended after the ENDE_V8_FLAGS environment variable.

--vendor

Toggles local vendor folder usage for remote modules.

--watch

Watch for file changes and restart process automatically. Local files from entry point module graph are watched by default. Additional paths might be watched by passing them as arguments to this flag.

--watch-exclude

Exclude provided files/patterns from watch mode.