deno/tests/specs
snek 4ddd342d8f
Some checks are pending
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build libs (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
refactor(unstable): improved arg handling and metadata (#30772)
2025-09-19 16:36:47 +02:00
..
add feat(install): refresh install report (#30615) 2025-09-08 09:44:22 +00:00
bench feat(install): refresh install report (#30615) 2025-09-08 09:44:22 +00:00
bundle feat(bundle): support html entrypoint (#29856) 2025-09-09 12:18:10 -07:00
cache fix(check): ensure module not found errors are surfaced (#30181) 2025-07-23 17:57:08 -04:00
cert refactor: extract out FileFetcher to deno_cache_dir (#27263) 2024-12-16 23:39:40 +00:00
check fix(check): filter resolution errors for bare ambient modules (#30690) 2025-09-12 17:44:13 +01:00
clean fix(install): clean-up lock poll file for a more deterministic node_modules folder output (#29623) 2025-06-06 12:58:10 -04:00
cli feat(otel): support vsock transport for telemetry (#30001) 2025-07-07 13:43:43 +00:00
compile feat(install): refresh install report (#30615) 2025-09-08 09:44:22 +00:00
coverage test: fix specs::coverage::data_url test (#29865) 2025-06-24 16:22:28 +05:30
doc feat(doc): add darkmode for HTML output (#28989) 2025-04-21 13:02:50 -07:00
eval fix: support cjs, cts, mjs, and mts for the --ext flag (#30398) 2025-08-14 12:02:49 -04:00
flags
fmt feat(BREAKING/fmt): prompt or require deno fmt . when providing no files and no config files discovered (#30623) 2025-09-08 14:28:47 -04:00
future
future_install_node_modules feat(install): refresh install report (#30615) 2025-09-08 09:44:22 +00:00
import_map/import_map_config
info feat(install): refresh install report (#30615) 2025-09-08 09:44:22 +00:00
init
install fix(check): filter resolution errors for bare ambient modules (#30690) 2025-09-12 17:44:13 +01:00
jsr fix: improve handling of linked jsr packages in lockfile (#30289) 2025-08-04 11:30:48 +02:00
jupyter/install_command feat(jupyter): allow to install and maintain multiple kernels (#29249) 2025-05-13 16:56:16 +00:00
lint feat(lint): no-unversioned-import rule (#30609) 2025-09-03 22:05:20 +00:00
lockfile feat(install): refresh install report (#30615) 2025-09-08 09:44:22 +00:00
node fix(node): improve directory import error suggestion (#30619) 2025-09-04 21:48:19 -04:00
npm test: de-flake specs tests in deno install (#30645) 2025-09-09 08:57:35 +00:00
outdated chore: make specs::outdated::pre_release_latest_tag less flaky (#30474) 2025-08-20 20:18:55 +00:00
permission feat: Add --deny-import flag (#29702) 2025-06-28 12:59:18 +00:00
publish fix: upgrade to swc_ecma_parser 23 (#30564) 2025-08-29 15:36:36 -04:00
remove feat(lockfile): default to lockfile v5 (#28950) 2025-04-17 13:27:37 -07:00
repl fix(unstable): fix json repl bugs (#30415) 2025-08-16 17:38:14 +02:00
run refactor(unstable): improved arg handling and metadata (#30772) 2025-09-19 16:36:47 +02:00
serve fix(serve): actually wire up resolving main module with import map for deno serve (#29974) 2025-07-02 11:29:23 -07:00
task feat(install): refresh install report (#30615) 2025-09-08 09:44:22 +00:00
test fix(permissions): point to correct config file in error message in workspace containing permissions at root (#30742) 2025-09-16 14:42:15 +00:00
upgrade chore: fix two locally failing on windows tests (#27845) 2025-01-28 10:46:43 -05:00
vendor/removed fix: add another space after warning symbol (#30482) 2025-08-26 08:19:51 -07:00
worker
workspaces fix(unstable): rename "patch" property to "links" (#29677) 2025-06-10 21:51:23 +00:00
mod.rs fix(tests): Switch from --nocapture to --no-capture (#30638) 2025-09-08 10:40:56 +02:00
README.md fix(tests): Switch from --nocapture to --no-capture (#30638) 2025-09-08 10:40:56 +02:00
schema.json fix(npm): do not error on failure to write warned script file (#30479) 2025-08-21 19:35:04 -04:00

specs

These are integration tests that execute the deno binary. They supersede the itest macro found in the tests/integration folder and are the preferred way of writing tests that use the deno binary.

Structure

Tests must have the following directory structure:

tests/specs/<category_name>/<test_name>/__test__.json

Test filtering

To run a specific test, run:

cargo test specs::category_name::test_name

Or just the following, though it might run other tests:

cargo test test_name

To run showing the output of every test use -- --no-capture (note: this will cause tests to run sequentially instead of in parallel):

cargo test test_name -- --no-capture

__test__.json file

This file describes the test(s) to execute and the steps to execute. A basic example looks like:

{
  "args": "run main.js",
  "output": "main.out"
}

This will run deno run main.js then assert that the output matches the text in main.out.

Or another example that runs multiple steps:

{
  "tempDir": true,
  "steps": [{
    "args": "cache main.ts",
    "output": "cache.out"
  }, {
    "args": "run main.ts",
    "output": "error.out",
    "exitCode": 1
  }]
}

Or if you want to run several tests at the same time:

{
  "tests": {
    "ignore_dir": {
      "args": "run script.ts",
      "output": "script.out"
    },
    "some_other_test": {
      "args": "run other.ts",
      "output": "other.out"
    }
  }
}

Top level properties

  • repeat (number) - Number of times to repeat a test.
  • tempDir (boolean) - Copy all the non-test files to a temporary directory and execute the command in that temporary directory.
    • By default, tests are executed with a current working directory of the test, but this may not be desirable for tests such as ones that create a node_modules directory.

Step properties

When writing a single step, these may be at the top level rather than nested in a "steps" array or "tests" object.

  • args - A string (that will be split on whitespace into an args array) or an array of arguments.
  • output - Path to use to assert the output or text (must end with an .out extension) or text to pattern match against the output.
  • flaky - Step should be repeated until success a maximum of 3 times.
  • if ("windows", "linux", "mac", "unix") - Whether to run this step.
  • exitCode (number) - Expected exit code.

Auto-complete

To get auto-complete for these files, add the following to a local .vscode/settings.json file:

{
  "json.schemas": [{
    "fileMatch": [
      "__test__.jsonc"
    ],
    "url": "./tests/specs/schema.json"
  }]
}

.out files

.out files are used to assert the output when running a test or test step.

Within the file, you can use the following for matching:

  • [WILDCARD] - match any text at the wildcard
  • [WILDLINE] - match any text on the current line
  • [WILDCHAR] - match the next character
  • [WILDCHARS(5)] - match any of the next 5 characters
  • [UNORDERED_START] followed by many lines then [UNORDERED_END] will match the lines in any order (useful for non-deterministic output)
  • [# example] - line comments start with [# and end with ]