@joystick.js/cli

test

Run tests for an existing Joystick app.

To run tests in standalone mode for an existing Joystick app, from your terminal, run:

joystick test

This will start a mirror of your app on port 1977 and run all of your app's tests against it.

File Targeting and Pattern Matching

The joystick test command supports powerful file targeting and pattern matching to run specific tests:

Run specific test files

# Run a specific test file
joystick test --file tests/lib/add.test.js
joystick test -f tests/lib/add.test.js

# Run tests matching a pattern
joystick test --match "lib/*"
joystick test -m "lib/*"

Use glob patterns

# Run all tests in a directory
joystick test --file "tests/lib/*.test.js"

# Run tests with specific naming patterns
joystick test --file "tests/**/*auth*.test.js"

Use regex patterns

# Run tests matching a regex (wrap in forward slashes)
joystick test --file "/.*auth.*/"
joystick test --file "/.*database.*/"

Note: The --match and --file flags are aliases and can be used interchangeably.

Watch Mode

Joystick has two options for running your tests in watch mode:

  1. As a traditional, standalone process (in another terminal) that watches for app changes and reruns your tests as normal.
  2. As an integrated process that runs your app's tests and reports their results directly inside of your app's server logs.

Traditional Watch Mode

To run your tests in traditional watch mode, run:

joystick test --watch

This will start a separate process that runs your tests and reruns them whenever file changes are detected.

Watch Mode with File Targeting

You can combine watch mode with file targeting to watch and run only specific tests:

# Watch specific test files
joystick test --watch --file "tests/lib/*.test.js"
joystick test -w -f "tests/lib/*.test.js"

# Watch tests matching a pattern
joystick test --watch --match "auth"
joystick test -w -m "auth"

# Watch tests matching a regex
joystick test --watch --file "/.*database.*/"

Integrated Watch Mode

Joystick's integrated watch mode is designed to run directly alongside your Joystick app.

This makes it far easier to do TDD with Joystick and encourages better testing practices as your test results are output right alongside your dev server's logs (no need to maintain multiple terminals just to do TDD).

In order to run tests in integrated watch mode, just start your app with the --tests flag:

joystick start --tests

This will start a mirror of your app on port 1977 and run all of your app's tests against it at startup time and then again whenever your app's source changes.