W3cubDocs

/Deno 2

deno test

Command line usage:
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

--check

Set 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

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

Dependency management options

--cached-only

Require that remote dependencies are already cached.

--frozen

Error out if lockfile is out of date.

--import-map

Load import map file from local file or remote URL.

--lock

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

--no-lock

Disable auto discovery of the lock file.

--no-npm

Do not resolve npm modules.

--no-remote

Do not resolve remote modules.

--node-modules-dir

Sets the node modules management mode for npm packages.

--reload

Short flag: -r

Reload 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

Toggles local vendor folder usage for remote modules and a node_modules folder for npm packages.

Options

--allow-scripts

Allow running npm lifecycle scripts for the given packages Note: Scripts will only be executed when using a node_modules directory (--node-modules-dir).

--cert

Load certificate authority from PEM encoded file.

--conditions

Use this argument to specify custom conditions for npm package exports. You can also use DENO_CONDITIONS env var. .

--config

Short flag: -c

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

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.

--hide-stacktraces

Hide stack traces for errors in failure test results.

--ignore

Ignore files.

--location

Value of globalThis.location used by some web APIs.

--no-config

Disable automatic loading of the configuration file.

--parallel

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

--preload

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

--seed

Set the random number generator seed.

--v8-flags

To 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

--inspect

Activate inspector on host:port [default: 127.0.0.1:9229]

--inspect-brk

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

--inspect-wait

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

Testing options

--clean

Empty 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

Collect 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-only

Only collect raw coverage data, without generating a report.

--doc

Evaluate code blocks in JSDoc and Markdown.

--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.

--junit-path

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

--no-run

Cache test modules, but don't run tests.

--permit-no-files

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

--reporter

Select reporter to use. Default to 'pretty'.

--shuffle

Shuffle the order in which the tests are run.

--trace-leaks

Enable tracing of leaks. Useful when debugging leaking ops in test, but impacts test execution time.

File watching options

--no-clear-screen

Do not clear terminal screen when under watch mode.

--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.

Additional information

It can be executed in watch mode (--watch), supports parallel execution (--parallel), and can be configured to run tests in a random order with (--shuffle). Additionally, there is built in support for code coverage (--coverage) and leak detection (--trace-leaks).

Examples

Run tests

deno test

Run tests in specific files

deno test src/fetch_test.ts src/signal_test.ts

Run tests where glob matches

deno test src/*.test.ts

Run tests and skip type-checking

deno test --no-check

Run tests, re-running on file change

deno test --watch

© 2018–2025 the Deno authors
Licensed under the MIT License.
https://docs.deno.com/runtime/reference/cli/test