Before getting started, you will need to install Node.js >= 18, it is recommended to use the Node.js LTS version.
Check the current Node.js version with the following command:
If you do not have Node.js installed in current environment, or the installed version is too low, you can use nvm or fnm to install.
Here is an example of how to install via nvm:
You can install Rstest using the following command:
Next, you need to update the npm scripts in your package.json to use Rstest's CLI commands.
After completing the above steps, you can run the Rstest tests using npm run test
, yarn test
, or pnpm test
. Alternatively, you can directly use npx rstest
to execute the Rstest tests.
Rstest has built-in commands such as watch
and run
, please refer to CLI Tools to learn about all available commands and options.
As a simple example, we have a sayHi
method. To test it, you can create a test file called index.test.ts
or use In-Source test similar to Rust Test.
Next, you can execute the test by using the command configured in Using Rstest. Rstest will print the following message: