CI Tests
Learn how to test your Makerkit in your CI
To run your tests in any CI, we recommend you simply run the following command:
npm test
This command takes care of running all the required services, importing the test data, executing the tests and then exiting.
The Makerkit testing pipeline
As mentioned in the previous section, testing a Makerkit requires a few services to be up and running:
- the Remix server
- the Firebase emulators
- optionally, the Stripe Mock server
While executing these tests in your CI, this can get cumbersome. Therefore, we provided a single script to execute all your tests in one simple command: you can find the script at scripts/test.sh
, which will contain the following content:
set -enpm run dev:test & npm run stripe:mock-server &npm run cypress:headlesssh scripts/kill-ports.sh
Let's explain it, so you can add your own modifications to it.
The first command will run (in parallel and in the background) the Remix server and the Stripe mock server:
npm run dev:test & npm run stripe:mock-server &
Afterward, we execute the Cypress tests in headless mode:
npm run cypress:headless
Finally, we clean up all the ports that may have remained open after executing the script:
sh scripts/kill-ports.sh
If you update your ports, remember to change them also in scripts/kill-ports.sh
.
Running the Tests in CI mode
Finally, the tests can be executed with the command npm test
.
This command will automatically run the Firebase emulators and the test.sh
script, and is defined as:
"test": "firebase emulators:exec --project demo-makerkit --import ./firebase-seed \"sh ./scripts/test.sh\"",
When finished, the emulators will exit.