deno/tests/specs
Boye Lillejord-Nygård ef6ff554b0
fix(bench): Make output table markdown compatible (#29532)
This changes the format of the table outputted by `deno bench` to be
markdown compatible.

Related #29533 
Closes #29466
2025-06-24 11:27:42 +02:00
..
add feat(lockfile): default to lockfile v5 (#28950) 2025-04-17 13:27:37 -07:00
bench fix(bench): Make output table markdown compatible (#29532) 2025-06-24 11:27:42 +02:00
bundle fix(bundle): transform import.meta.main (#29830) 2025-06-23 20:51:24 +00:00
cache feat(lockfile): default to lockfile v5 (#28950) 2025-04-17 13:27:37 -07:00
cert refactor: extract out FileFetcher to deno_cache_dir (#27263) 2024-12-16 23:39:40 +00:00
check fix(check): ignore errors on ambient modules (#29135) 2025-05-16 15:06:34 +09: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 tests(otel): ensure delta temporality is working (#29602) 2025-06-05 10:19:41 +02:00
compile fix(unstable): rename "patch" property to "links" (#29677) 2025-06-10 21:51:23 +00:00
coverage fix(coverage): Make output table markdown compatible (#29533) 2025-06-24 11:27:07 +02:00
doc feat(doc): add darkmode for HTML output (#28989) 2025-04-21 13:02:50 -07:00
eval feat(node): stabilize detecting if CJS via "type": "commonjs" in a package.json (#26439) 2024-11-13 15:10:09 +00:00
flags feat: add lowercase -v version flag (#23750) 2024-05-23 00:20:20 +00:00
fmt fix(fmt): handle TS as syntax in Svelte each block (#29789) 2025-06-17 20:10:06 +02:00
future chore: upgrade to rust 1.82 and LLVM 19 (#26615) 2024-11-01 16:13:02 +05:30
future_install_node_modules feat(lockfile): default to lockfile v5 (#28950) 2025-04-17 13:27:37 -07:00
import_map/import_map_config refactor: move importMap with imports/scopes diagnostic to deno_config (#24553) 2024-07-12 12:48:53 -04:00
info feat(info): include deno version (#29080) 2025-04-28 18:41:30 +01:00
init feat(init): add --npm flag to initialize npm projects (#26896) 2024-11-21 00:03:11 +00:00
install fix(install,outdated): try to avoid building graph with incorrect exports (#29713) 2025-06-12 09:23:05 -07:00
jsr fix(jsr): allow using import.meta.resolve to resolve non-jsr remote urls (#29831) 2025-06-20 22:05:38 +00:00
jupyter/install_command feat(jupyter): allow to install and maintain multiple kernels (#29249) 2025-05-13 16:56:16 +00:00
lint feat(unstable): support comments in lint plugin (#29189) 2025-05-08 21:59:36 +02:00
lockfile fix(npm): respect etag for npm packument caching (#29130) 2025-05-02 09:49:05 -04:00
node fix(ext/node): createInterface doesn't require env permission (#29472) 2025-05-28 11:59:26 +02:00
npm fix: remove self from global middleware (#29734) 2025-06-13 12:48:26 +02:00
outdated fix(install,outdated): try to avoid building graph with incorrect exports (#29713) 2025-06-12 09:23:05 -07:00
permission fix(permissions): implicit --allow-import when using --cached-only (#27530) 2025-01-02 16:55:03 -05:00
publish feat: code sign deno.exe (#28963) 2025-04-25 08:27:12 +02:00
remove feat(lockfile): default to lockfile v5 (#28950) 2025-04-17 13:27:37 -07:00
repl/console_log chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
run fix: import.meta.resolve - do not error for non-existent files in npm packages (#29741) 2025-06-16 12:03:12 +02:00
serve feat: add DENO_AUTO_SERVE env var (#29852) 2025-06-24 11:05:59 +02:00
task fix(process,node): roll our own process spawning on windows (#29609) 2025-06-12 02:56:13 +00:00
test fix(node/test): basic support for t.skip and t.todo (#29222) 2025-05-09 01:40:16 +02:00
upgrade chore: fix two locally failing on windows tests (#27845) 2025-01-28 10:46:43 -05:00
vendor/removed fix: add info suggestion for unsafely-ignore-certificate-errors and add --help=full (#28203) 2025-02-24 08:20:59 -08:00
worker feat: add --allow-import flag (#25469) 2024-09-26 01:50:54 +00:00
workspaces fix(unstable): rename "patch" property to "links" (#29677) 2025-06-10 21:51:23 +00:00
mod.rs refactor(install): support tarball extract in Wasm (#29587) 2025-06-04 13:51:26 +00:00
README.md docs: fix a typo in specs README.md (#28524) 2025-03-17 17:46:22 +09:00
schema.json refactor(install): support tarball extract in Wasm (#29587) 2025-06-04 13:51:26 +00: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 -- --nocapture (note: this will cause tests to run sequentially instead of in parallel):

cargo test test_name -- --nocapture

__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 ]