Solution development - Local testing sequence
Incremental Testing Strategy
It's a no-brainer for anyone working at the solution level, but let's restate it clearly. The following strategy ensures the solution functions correctly at every stage—progressing from local development through building, containerization, and finally system integration.
TL:DR;
1. Test Local Development Environment and
2. Test Product Build Process
3. Test Docker Standalone
4. Test Docker Compose Integration
- Test Local Development Environment
1.1 Test product local development setup by running the construct development server:
npm run dev
Confirm the product runs successfully at "http://localhost:PORT".
1.2 Test product local tests are green Run the tests:
npm run test
Ensure all tests pass and no issues are reported.
- Test Product Build Process Ensure the product builds without (unexpected?) warnings: execute the build process:
npm run build
Address any warnings that appear during the build.
- Test Docker Standalone Packaging Ensure the product can be packaged and run standalone using Docker and Nginx: Build the Docker image without cache:
docker build --no-cache -t app-target-docker-alone .
Run the Docker container with the following configuration:
docker run -it --name app-target-docker-alone \
-e ENV_NODE_ENV=production \
-e ENV_DPLMNT_ENV=production \
-e ENV_PROJECT_ID=production \
-e ENV_APP_URL=http://localhost:PORT \
-p 8080:8080 \
app-target-docker-alone
Verify that the product is running on http://localhost:8080.
- Test Docker Compose Integration Ensure the product can be serviced as part of a system solution using Docker Compose:
# Stop and remove any existing containers:
docker-compose down --volume
# Rebuild and start the containers:
docker-compose up --build -d
Verify that the product is running correctly on port 9090 (http://localhost:9090).
- Run the e2e tests Have a separate repo for the e2e tests (eg. robot, cypress, etc), and run it against the docker compose urls.
--
If your CI is dirt cheap, push first, open a draft PR, and have an automation pipeline to feedback over all stages. The pipeline should fail without proceeding further in the sequence.
Hope this helps. Thanks for reading.