test(webapp): provide an environment variable for e2e tests

This commit is contained in:
fastium
2025-06-24 18:48:43 +02:00
parent 9967aef1f5
commit 4e5959fac4
4 changed files with 14 additions and 6 deletions

View File

@@ -40,17 +40,14 @@ web-app-unit-tests:
web-app-e2e-tests:
image: $NODE_IMAGE
stage: web-app-tests
# services:
# - name: $DOCKER_IMAGE
# alias: app
script:
- export CYPRESS_TEST_URL=$TEST_URL
- echo "Running e2e tests"
- apt-get update
- apt-get install curl
- cd ./web-app
- npm install --include=dev
- echo "Wait web-app app is running"
- for i in {1..6}; do curl -f https://app.mse.kb28.ch/ && break || sleep 5; done
- for i in {1..6}; do curl -f $CYPRESS_TEST_URL && break || sleep 5; done
- echo "App is running"
- npm run test:e2e

View File

@@ -2,7 +2,7 @@
describe("Test fetch measurments button in the main page", () => {
beforeEach(() => {
cy.visit("https://app.mse.kb28.ch");
cy.visit(Cypress.env("TEST_URL"));
});
it("Fetch timeseries with valid user-room-device", () => {

View File

@@ -25,6 +25,16 @@ cd ./web-app
npm install --inlude=dev
```
### Before Running Tests
A test url is needed to perform the tests in local:
```bash
export CYPRESS_TEST_URL=http://your-test-url.com
```
Note: most of the time, if you are testing in local, you can use:
```bash
export CYPRESS_TEST_URL=http://localhost:8080/
```
### Run unit Tests
```bash
npm run test:unit