- Next.js Firebase
- Running Tests
Learn how to run Cypress E2E tests for your Makerkit application
The Makerkit SaaS boilerplate comes with a set of predefined tests with the following goals:
- Verify that the boilerplate application works well
- Provide instructions for building your own tests
As your application grows, the tests will inevitably need to be updated and maintained. We hope that our tests will be simple to understand and to change when you will need them.
First, we have to run the following command to run Next.js with a testing
environment (i.e. using
npm run dev:test
This command will start a Next.js dev server at http://localhost:3000, so it's important to make sure you have no other Next.js server running at the same port.
Additionally, we have to start the Firebase Emulator server:
npm run firebase:emulators:start
While you build your tests, it can be handy to use a windowed version of the Cypress testing suite, so that you can easily retry the tests without having to re-run the while tests suite.
To do that, run the following command:
npm run cypress
Whenever you want to run all your tests at once, you can use the following commands:
npm run cypress:headless
This will run all the tests and exit.
Whenever you want to run all your tests in a CI environment, you can use the following commands:
The command above will:
- Start the Firebase Emulator
- Start the Next.js environment
- Run the tests in headless mode
- Exit and close all the processes
As you may have noticed, this is the command to run in your CI environment.
Testing Stripe requires one more process to start, i.e. the official Stripe emulator.
The command below will require Docker installed, which is why you can
choose to disable it by setting the environment variable
false from the
.env.test environment file:
If instead, you want to test Stripe Checkout as well, run the command below:
npm run stripe:mock-server
As we've mentioned, this will require Docker running. Of course, we think it's worth it.