Skip to main content

Add Test

Scaffold a new .test.ts in the nearest tests/ folder so it runs with the test workflow.

Purpose

  • Create a test quickly in the right location.
  • Keep tests organized alongside the code under test.

When To Use

  • Adding coverage for a feature, workflow, or contract.

CLI

  • webstir add-test <name-or-path>

Inputs

  • <name-or-path>: file name or relative path. The workflow resolves the closest tests/ folder from the provided context.

Steps

  1. Resolve target tests/ folder.
  2. Delegate to the @webstir-io/webstir-testing TypeScript CLI (webstir-testing-add) which writes the template if it does not already exist.
  3. Ensure the workspace depends on the configured testing provider (default @webstir-io/webstir-testing) so the Node test runner can execute—webstir install reconciles dependencies based on webstir.providers.json.

Outputs

  • New test file: <resolved-tests-folder>/<name>.test.ts.

Errors & Exit Codes

  • Non-zero if the path is invalid, the file exists, or file IO fails.