diff --git a/cypress.config.ts b/cypress.config.ts index 4bd27e952..3b8523d2c 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -8,6 +8,13 @@ if (!process.env.RUN_AGAINST_LOCAL_SERVICES) { dotenv.config({ path: import.meta.dirname + '/integration-tests/.env' }); } +if (process.env.RUN_AGAINST_LOCAL_SERVICES === '1') { + const dotenv = await import('dotenv'); + dotenv.config({ path: import.meta.dirname + '/packages/services/server/.env.template' }); + // It seems that this has to be set in the environment that the cypress cli is executed from. + // process.env.CYPRESS_BASE_URL = process.env.CYPRESS_BASE_URL ?? 'http://localhost:3000'; +} + const isCI = Boolean(process.env.CI); export const seed = initSeed(); diff --git a/docs/TESTING.md b/docs/TESTING.md index fbcec6f70..7c2ee59fd 100644 --- a/docs/TESTING.md +++ b/docs/TESTING.md @@ -65,12 +65,14 @@ To run integration tests locally, from the pre-build Docker image, follow: ## E2E Tests -e2e Tests are based on Cypress, and matches files that ends with `.cy.ts`. The tests flow runs from -a pre-build Docker image. +We use [Cypress](https://www.cypress.io). Any file that ends with `.cy.ts` is an E2E test. -#### Running on built Docker images from source code +#### Running Against Local Development Services -To run e2e tests locally, from the local source code, follow: +1. Run the [development setup](./DEVELOPMENT.md) as usual. +2. Run `pnpm test:e2e:local` + +#### Running Against Locally Built Docker Images 1. Make sure you have Docker installed. If you are having issues, try to run `docker system prune` to clean the Docker caches. @@ -79,9 +81,7 @@ To run e2e tests locally, from the local source code, follow: 4. Run `./local.sh` for building the project and starting the Docker containers 5. Follow the output instruction from the script for starting the tests -#### Running from pre-built Docker image - -To run integration tests locally, from the pre-build Docker image, follow: +#### Running Against Pre-Built Docker Images 1. Make sure you have Docker installed. If you are having issues, try to run `docker system prune` to clean the Docker caches. diff --git a/package.json b/package.json index af7377c12..3773cbd10 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "start": "pnpm run local:setup", "test": "vitest", "test:e2e": "CYPRESS_BASE_URL=$HIVE_APP_BASE_URL cypress run --browser chrome", + "test:e2e:local": "CYPRESS_BASE_URL=http://localhost:3000 RUN_AGAINST_LOCAL_SERVICES=1 cypress open --browser chrome", "test:e2e:open": "CYPRESS_BASE_URL=$HIVE_APP_BASE_URL cypress open", "test:integration": "cd integration-tests && pnpm test:integration", "typecheck": "pnpm run -r --filter '!hive' typecheck",