On this page
deno test
Deno ships with a built-in test runner using the
Deno.test() API. To learn how to write tests, see the
Testing fundamentals guide. For assertions,
see @std/assert and
@std/expect.
Running tests Jump to heading
Run all tests in the current directory and subdirectories:
deno test
Run tests in specific files:
deno test src/fetch_test.ts src/signal_test.ts
Run tests matching a glob pattern:
deno test src/*.test.ts
Run tests whose name matches a string or pattern:
deno test --filter "database"
deno test --filter "/^connect.*/"
Skip type-checking:
deno test --no-check
Permissions Jump to heading
Tests run with the same permission model as
deno run. Grant permissions for your test suite:
deno test --allow-read --allow-net
Watch mode Jump to heading
Re-run tests automatically when files change:
deno test --watch
Parallel execution Jump to heading
Run test files across multiple worker threads:
deno test --parallel
By default, --parallel uses the number of available CPUs. Use DENO_JOBS=<N>
to control the number of threads:
DENO_JOBS=4 deno test --parallel
Code coverage Jump to heading
Collect coverage data and generate a report:
deno test --coverage
This writes raw coverage data to a coverage/ directory. To generate a summary
from existing coverage data, use
deno coverage:
deno coverage coverage/
You can also output an lcov report for use with external tools:
deno coverage --lcov coverage/ > coverage.lcov
Reporters Jump to heading
Choose an output format with --reporter:
deno test --reporter=dot
deno test --reporter=tap
Write a JUnit XML report for CI systems:
deno test --junit-path=report.xml
Randomize order Jump to heading
Shuffle the order tests run in to catch hidden dependencies between tests:
deno test --shuffle
Leak detection Jump to heading
Trace the source of leaked async operations, timers, or resources:
deno test --trace-leaks
Testing code in documentation Jump to heading
Evaluate code blocks in JSDoc and Markdown files as tests:
deno test --doc
See Testing code in docs for details.
deno test [OPTIONS] [files]... [-- [SCRIPT_ARG]...]Run tests using Deno's built-in test runner.
Evaluate the given modules, run all tests declared with Deno.test() and report results to standard output:
deno test src/fetch_test.ts src/signal_test.ts
Directory arguments are expanded to all contained files matching the glob {*_,*.,}test.{js,mjs,ts,mts,jsx,tsx}
or **/__tests__/**:
deno test src/
Type checking options Jump to heading
--check<CHECK_TYPE>optionalSet type-checking behavior. This subcommand type-checks local modules by default, so adding --check is redundant
If the value of "all" is supplied, remote modules will be included.
Alternatively, the 'deno check' subcommand can be used.
--no-check<NO_CHECK_TYPE>optionalSkip type-checking. If the value of "remote" is supplied, diagnostic errors from remote modules will be ignored.
Dependency management options Jump to heading
--cached-onlyRequire that remote dependencies are already cached.
--frozen<BOOLEAN>optionalError out if lockfile is out of date.
Load import map file from local file or remote URL.
--lock<FILE>optionalCheck the specified lock file. (If value is not provided, defaults to "./deno.lock").
--no-lockDisable auto discovery of the lock file.
--no-npmDo not resolve npm modules.
--no-remoteDo not resolve remote modules.
--node-modules-dir<MODE>optionalSets the node modules management mode for npm packages.
--reload, -r<CACHE_BLOCKLIST>optionalReload source code cache (recompile TypeScript) no value Reload everything jsr:@std/http/file-server,jsr:@std/assert/assert-equals Reloads specific modules npm: Reload all npm modules npm:chalk Reload specific npm module.
--vendor<vendor>optionalToggles local vendor folder usage for remote modules and a node_modules folder for npm packages.
Options Jump to heading
--allow-scripts<PACKAGE>optionalAllow running npm lifecycle scripts for the given packages
Note: Scripts will only be executed when using a node_modules directory (--node-modules-dir).
--cert<FILE>Load certificate authority from PEM encoded file.
--conditions<conditions>Use this argument to specify custom conditions for npm package exports. You can also use DENO_CONDITIONS env var. .
Configure different aspects of deno including TypeScript, linting, and code formatting.
Typically the configuration file will be called deno.json or deno.jsonc and
automatically detected; in that case this flag is not necessary.
--env-file<FILE>optionalLoad 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<ext>Set content type of the supplied file.
--hide-stacktracesHide stack traces for errors in failure test results.
--ignore<ignore>Ignore files.
--location<HREF>Value of globalThis.location used by some web APIs.
--minimum-dependency-age<minimum-dependency-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-configDisable automatic loading of the configuration file.
--parallelRun test modules in parallel. Parallelism defaults to the number of available CPUs or the value of the DENO_JOBS environment variable.
--preload<FILE>A list of files that will be executed before the main module.
--require<FILE>A list of CommonJS modules that will be executed before the main module.
--seed<NUMBER>Set the random number generator seed.
--v8-flags<V8_FLAGS>optionalTo see a list of all available flags use --v8-flags=--help
Flags can also be set via the DENO_V8_FLAGS environment variable.
Any flags set with this flag are appended after the DENO_V8_FLAGS environment variable.
Debugging options Jump to heading
--inspect<HOST_PORT>optionalActivate 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<HOST_PORT>optionalActivate inspector on host:port, wait for debugger to connect and break at the start of user script.
--inspect-wait<HOST_PORT>optionalActivate inspector on host:port and wait for debugger to connect before running user code.
Testing options Jump to heading
--cleanEmpty the temporary coverage profile data directory before running tests.
Note: running multiple deno test --clean`` calls in series or parallel for the same coverage directory may cause race conditions.
--coverage<DIR>optionalCollect coverage profile data into DIR. If DIR is not specified, it uses 'coverage/'. This option can also be set via the DENO_COVERAGE_DIR environment variable.
--coverage-raw-data-onlyOnly collect raw coverage data, without generating a report.
--docEvaluate code blocks in JSDoc and Markdown.
--fail-fast<N>optionalStop after N errors. Defaults to stopping after first failure.
--filter<filter>Run tests with this string or regexp pattern in the test name.
--junit-path<PATH>Write a JUnit XML test report to PATH. Use '-' to write to stdout which is the default when PATH is not provided.
--no-runCache test modules, but don't run tests.
--permit-no-filesDon't return an error code if no files were found.
--reporter<reporter>Select reporter to use. Default to 'pretty'.
--shuffle<NUMBER>optionalShuffle the order in which the tests are run.
--trace-leaksEnable tracing of leaks. Useful when debugging leaking ops in test, but impacts test execution time.
File watching options Jump to heading
--no-clear-screenDo not clear terminal screen when under watch mode.
--watch<FILES>optionalWatch 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<FILES>optionalExclude provided files/patterns from watch mode.