Community - Testing

Found an error? Have a suggestion?Edit this page on GitHub

How to run and add tests for the generator. For local setup see Development setup.

Running Tests Locally

To run all tests locally:

  • Unit tests: npm run generator:test:unit
  • Integration tests: npm run generator:test:integration

Adding tests

  1. Create new test files in the appropriate directory under apps/generator/test/.

  2. Follow the existing test patterns.

  3. Run your new tests using the commands listed above.

Running Tests in Docker

To run tests in an isolated Docker environment:

  1. Ensure Docker is installed and running on your machine, with Docker Compose v2 (the docker compose command, not the legacy docker-compose v1). The Compose configuration files use the pull_policy key, which is only supported by Compose v2.

  2. Run the following command from the project root:

docker compose up

You can also choose to run the lint checks after the tests complete by setting an environment variable LINT with any value before the command:

  • Windows: set LINT=true && docker compose up
  • Linux/macOS: LINT=true docker compose up

Manually testing with test templates

To test template features manually, use the react-template located in apps/generator/test/test-templates. You can run your changes against this template as follows:

  1. Navigate to the generator directory:
cd apps/generator
  1. Modify the react-template in ./test/test-templates/react-template to test different features.

  2. Run the generator against the the test template:

node ./test/cli ./test/docs/dummy.yml ./test/test-templates/react-template -o ./test/output --force-write
  1. Check the ./test/output directory to confirm it matches the output you expected.
Was this helpful?
Help us improve the docs by sharing your feedback.