We are using Vitest.
Simply run pnpm test
to run all the tests locally.
We are using Vitest to test the following concerns:
- Main application flows and integration of different services
- Containerize execution of all services
- Cross-service network calls
Integration tests are based pre-built Docker images, so you can run it in 2 modes:
**To run integration tests locally with a built artifact, you need to build a Docker image for the services. **
Use pnpm integration:prepare
command to set up the complete environment from locally running
integration tests.
And then, to run the tests, use the following:
pnpm test:integration
Make sure to run the prepare command every time you change your code.
You can also run integration tests against the local-running services, during development.
To do so, use the following instructions:
- Run Hive from VSCode (using
Start Hive
button). - Make sure all services are running correctly.
- Run integration tests with
pnpm dev:integration
command (from root directory).
To run integration tests locally, from the pre-build Docker image, follow:
-
Install all deps:
pnpm i
-
Generate types:
pnpm graphql:generate
-
Build only addition, local CF Workers source code, by running:
pnpm --filter integration-tests prepare:env
-
Decide on the commit ID / Docker image tag you would like to use (make sure
build-and-dockerize
is done successfully) -
Set the needed env vars, and use Docker Compose to run all local services:
export DOCKER_REGISTRY="ghcr.io/graphql-hive/" export DOCKER_TAG=":IMAGE_TAG_HERE" docker compose -f ./docker/docker-compose.community.yml -f ./integration-tests/docker-compose.integration.yaml --env-file ./integration-tests/.env up -d --wait
-
Run the tests:
pnpm --filter integration-tests test:integration
e2e Tests are based on Cypress, and matches files that ends with .cy.ts
. The tests flow runs from
a pre-build Docker image.
To run e2e tests locally, from the local source code, follow:
- Make sure you have Docker installed. If you are having issues, try to run
docker system prune
to clean the Docker caches. - Install all deps:
pnpm i
- Generate types:
pnpm graphql:generate
- Build source code:
pnpm build
- Set env vars:
export COMMIT_SHA="local" export RELEASE="local" export BRANCH_NAME="local" export BUILD_TYPE="" export DOCKER_TAG=":local"
- Compile a local Docker image by running:
docker buildx bake -f docker/docker.hcl build --load
- Run the e2e environment, by running:
docker compose -f ./docker/docker-compose.community.yml -f ./docker/docker-compose.end2end.yml --env-file ./integration-tests/.env up -d --wait
- Run Cypress:
pnpm test:e2e
To run integration tests locally, from the pre-build Docker image, follow:
- Make sure you have Docker installed. If you are having issues, try to run
docker system prune
to clean the Docker caches. - Install all deps:
pnpm i
- Generate types:
pnpm graphql:generate
- Build source code:
pnpm build
- Decide on the commit ID / Docker image tag you would like to use and set it as env var:
export DOCKER_REGISTRY="ghcr.io/graphql-hive/" export DOCKER_TAG=":IMAGE_TAG_HERE"
- Run the e2e environment, by running:
docker compose -f ./docker/docker-compose.community.yml --env-file ./integration-tests/.env up -d --wait
- Run Cypress:
pnpm test:e2e
Keep in mind that integration tests are running a combination of 2 Docker Compose files:
docker-compose.community.yml
- this is also used for self-hosting Hive, so this file contains all services and configurations needed for running Hive core (without Cloud-specific services, like billing).docker-compose.integration.yaml
- An extension and overrides file: we are using that file to run local services such as CloudFlare CDN mock, external composition service and so on - this is done in order to mock a complete Hive Cloud environment and test all features. This file also includes overrides such as environment variables that are specific only for integration testing - so make sure to choose wisely where to add environment variables!
If you are having issues with running Docker images, follow these instructions:
- Make sure you have the latest Docker installed.
- Make sure no containers are running (
docker ps
and thendocker stop CONTAINER_ID
). - Delete the local volume used for testing, it's located under
.hive
directory. - Try to run
docker system prune
to clean all the Docker images, containers, networks and caches.