Running tests
The code in Turboship is tested in three different ways:
- Static
- Unit
- and end-to-end tests.
Static Tests
Static tests are performed during the depeloper time. They are used to check the code for syntax errors, type errors, and other issues that can be detected without running the code.
They are performed using the eslint
and tsc
commands. You can run them using
the following commands:
bun run lint
bun run typecheck
Every time you commit code, the static tests will be run automatically by the
husky
package. This way, you can ensure that the code is always clean and
error-free. In case you need to disable the static tests, you can use the
--no-verify
flag when committing the code.
git commit -m "My commit message" --no-verify
Unit Tests
Unit tests are used to test individual units of code, such as functions or
classes. They are performed using the vitest
package. You can run them using
the following command:
bun run test
Every time you commit code, the unit tests will be run automatically by the CI/CD pipeline.
Unit tests are defined by the .test.ts
suffix in the file name.
End-to-End Tests
End-to-end tests are used to test the application as a whole. They are performed
using the playwright
package. You can run them using the following command:
bun run test:e2e
Every time you commit code, the end-to-end tests will be run automatically by the CI/CD pipeline.
End-to-end tests are defined by the .spec.ts
suffix in the file name.
Configuring GitHub Actions
The GitHub Actions workflow is defined in the .github/workflows/main.yml
file.
Edit the file to configure the workflow according to your needs and add the following configuration to your GitHub repository:
Feature | Name | Type | Description |
---|---|---|---|
E2E tests for payments | STRIPE_SECRET_KEY | Secret | It can be the same stripe test key used for development. eg: sk_test_... |
E2E tests for payments | DEFAULT_CTA_PRICE_ID | Environment | |
Turbo's remote caching | TURBO_TOKEN | Secret | Get yours from the tokens page. |
Turbo's remote caching | TURBO_TEAM | Environment | Your vercel username. You can get it from account page. eg: vercel.com/USERNAME |