Using the test command
Included as part of the main binary, Deno also provides a test runner. The command for it, not surprisingly, is called test
. In this section, we'll explore it and run a couple of tests.
In this section, we'll mainly explore the command itself and not the test syntax. We'll look at the syntax and best practices for it in more depth in a dedicated chapter later on the book.
The test
command finds files to run based on the {*_,*.,}test.{js,mjs,ts,jsx,tsx}
glob expression.
Since glob expressions might not be too intuitive to read, we'll explain them briefly.
It matches any files with the js
, mjs
, ts
, jsx
, and tsx
extensions and that have test
in their name preceded by an underscore (_
) or a dot (.
)
A few examples of files that will match the expression and be considered tests are as follows:
example.test.ts
example_test.js
example.test.jsx
example_test.mjs
Deno tests also run inside the sandbox environment...