Siesta is a stress-free JavaScript/TypeScript testing tool. It is ubiquitous - tests can be run in browsers, Node.js and Deno, on Linux, macOS and Windows.
In this guide, we assume a setup, pointed toward running tests in Node.js.
Siesta supports all maintained LTS releases of Node.js.
To launch several tests, you need to use the Siesta launcher. Siesta launcher is an executable file, called siesta. Usually to access it in your local package installation, you use the npx command, provided by the npm package manager:
npx siesta --help
To launch several tests, pass a matching glob pattern as the 1st argument for the launcher. It can be also a directory name, in such case Siesta will pick up all *.t.m?js files in it, recursively. To resolve the glob pattern, Siesta uses the glob npm library, please refer to its documentation for details on globs resolution.
IMPORTANT: Don't forget to quote your glob pattern with single quotes, otherwise it will be expanded by the shell.
Some examples:
Launch all tests in tests directory:
npx siesta tests
Launch all tests in tests directory, with custom extension:
npx siesta 'tests/**/*.test.js'
Launch all tests in tests directory, which have characters 1 or 2 in their names:
You can debug a Siesta test as any other regular Node.js script. For that, place the debugger statement somewhere in the test code and then start the test with the --inspect-brk option. Note, that due to this issue, starting your test with just --inspect may result in your breakpoint being ignored.
You need to place the --inspect-brk option right after the node executable, before the test file - otherwise it will be passed to the script, instead of the node.
For example, for the test above:
node --inspect-brk tests/basic/basic_test.t.js
Then open the console in any Chrome tab and click the "Dedicated DevTools for Node.js" icon in the bottom-left.
Getting started with Siesta in Node.js environment
Siesta is a stress-free JavaScript/TypeScript testing tool. It is ubiquitous - tests can be run in browsers, Node.js and Deno, on Linux, macOS and Windows.
In this guide, we assume a setup, pointed toward running tests in Node.js.
Siesta supports all maintained LTS releases of Node.js.
Installation
Basics
To familiarize yourself with the basic Siesta concepts, which are common for all execution environments, please check the Siesta test basics guide.
Importing API
When targeting Node.js environment for running tests, import the Siesta API from the
@bryntum/siesta/nodejs.js
entry file.Launching individual test
Let's assume we have the following Siesta test file, called
basic_test.t.js
.We can launch it, as a regular Node.js script:
You should see something like:
Launching several tests
To launch several tests, you need to use the Siesta launcher. Siesta launcher is an executable file, called
siesta
. Usually to access it in your local package installation, you use thenpx
command, provided by thenpm
package manager:To launch several tests, pass a matching glob pattern as the 1st argument for the launcher. It can be also a directory name, in such case Siesta will pick up all
*.t.m?js
files in it, recursively. To resolve the glob pattern, Siesta uses the glob npm library, please refer to its documentation for details on globs resolution.IMPORTANT: Don't forget to quote your glob pattern with single quotes, otherwise it will be expanded by the shell.
Some examples:
Launch all tests in
tests
directory:Launch all tests in
tests
directory, with custom extension:Launch all tests in
tests
directory, which have characters1
or2
in their names:Debugging
You can debug a Siesta test as any other regular Node.js script. For that, place the
debugger
statement somewhere in the test code and then start the test with the--inspect-brk
option. Note, that due to this issue, starting your test with just--inspect
may result in your breakpoint being ignored.You need to place the
--inspect-brk
option right after thenode
executable, before the test file - otherwise it will be passed to the script, instead of thenode
.For example, for the test above:
Then open the console in any Chrome tab and click the "Dedicated DevTools for Node.js" icon in the bottom-left.
Further reading
Configuring the test suite: Siesta project guide
COPYRIGHT AND LICENSE
MIT License
Copyright (c) 2009-2021 Bryntum, Nickolay Platonov