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
-
Create new test files in the appropriate directory under
apps/generator/test/. -
Follow the existing test patterns.
-
Run your new tests using the commands listed above.
Running Tests in Docker
To run tests in an isolated Docker environment:
-
Ensure Docker is installed and running on your machine, with Docker Compose v2 (the
docker composecommand, not the legacydocker-composev1). The Compose configuration files use thepull_policykey, which is only supported by Compose v2. -
Run the following command from the project root:
docker compose upYou 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
This approach ensures a clean environment for each test run by cleanly installing dependencies and running tests in a Docker container.
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:
- Navigate to the generator directory:
cd apps/generator-
Modify the react-template in
./test/test-templates/react-templateto test different features. -
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- Check the
./test/outputdirectory to confirm it matches the output you expected.