Documentation
    Preparing search index...

    Exposes the API to run Japa tests and optionally watch for file changes to re-run the tests.

    The TestRunner provides intelligent test execution with watch mode capabilities. When files change, it can selectively run specific tests or the entire suite based on what changed.

    The watch mode functions as follows:

    • If the changed file is a test file, then only tests for that file will be re-run.
    • Otherwise, all tests will re-run with respect to the initial filters applied when running the node ace test command.
    const testRunner = new TestRunner(cwd, { suites: [], hooks: [] })
    await testRunner.run()
    // Run tests in watch mode
    const testRunner = new TestRunner(cwd, { suites: [], hooks: [] })
    await testRunner.runAndWatch(ts, { poll: false })
    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    scriptFile: string = 'bin/test.ts'

    The script file to run as a child process

    cwd: URL

    The current working directory URL

    Test runner configuration options including filters, reporters, and hooks

    Accessors

    • get ui(): {}

      CLI UI instance to log colorful messages and progress information

      Returns {}

    • set ui(ui: {}): void

      CLI UI instance to log colorful messages and progress information

      Parameters

      • ui: {}

      Returns void

    Methods

    • Add listener to get notified when test runner is closed

      Parameters

      • callback: (exitCode: number) => any

        Function to call when test runner closes

      Returns this

      This TestRunner instance for method chaining

    • Add listener to get notified when test runner encounters an error

      Parameters

      • callback: (error: any) => any

        Function to call when test runner encounters an error

      Returns this

      This TestRunner instance for method chaining

    • Close watchers and running child processes

      Cleans up file system watchers and terminates any running test processes to ensure graceful shutdown.

      Returns Promise<void>

    • Runs tests once without watching for file changes

      Executes the test suite a single time and exits. This is the equivalent of running tests in CI/CD environments.

      Returns Promise<void>

    • Run tests in watch mode and re-run them when files change

      Starts the test runner in watch mode, monitoring the file system for changes and automatically re-running tests when relevant files are modified. Uses intelligent filtering to run only affected tests when possible.

      Parameters

      • ts: typeof ts

        TypeScript module reference for parsing configuration

      • Optionaloptions: { poll: boolean }

        Watch options including polling mode for file system monitoring

      Returns Promise<void>