From d419fd6ee4efd735cd230c7f0caf1d8ffb467728 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Mon, 9 Oct 2023 12:33:04 -0300 Subject: [PATCH] first shell script to run frontend tests --- src/frontend/playwright.config.ts | 19 +++++++++++++------ src/frontend/run-tests.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 6 deletions(-) create mode 100755 src/frontend/run-tests.sh diff --git a/src/frontend/playwright.config.ts b/src/frontend/playwright.config.ts index 6af6cb8d7..7899cb4cb 100644 --- a/src/frontend/playwright.config.ts +++ b/src/frontend/playwright.config.ts @@ -24,7 +24,7 @@ export default defineConfig({ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ - // baseURL: 'http://127.0.0.1:3000', + // baseURL: "http://127.0.0.1:3000", /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: "on-first-retry", @@ -69,9 +69,16 @@ export default defineConfig({ ], /* Run your local dev server before starting the tests */ - // webServer: { - // command: 'npm run start', - // url: 'http://127.0.0.1:3000', - // reuseExistingServer: !process.env.CI, - // }, + // webServer: [ + // { + // command: "npm run backend", + // reuseExistingServer: !process.env.CI, + // timeout: 120 * 1000, + // }, + // { + // command: "npm run start", + // url: "http://127.0.0.1:3000", + // reuseExistingServer: !process.env.CI, + // }, + // ], }); diff --git a/src/frontend/run-tests.sh b/src/frontend/run-tests.sh new file mode 100755 index 000000000..ec78c0641 --- /dev/null +++ b/src/frontend/run-tests.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Navigate to the project root directory (where the Makefile is located) +cd ../../ + +# Start the frontend using 'make frontend' in the background +make frontend & + +# Give some time for the frontend to start (adjust sleep duration as needed) +sleep 10 + +#Run frontend only Playwright tests +cd src/frontend && npx playwright test --ui tests/onlyFront + +# Start the backend using 'make backend' in the background +make backend & + +# Give some time for the backend to start (adjust sleep duration as needed) +sleep 10 + +# Navigate back to the test directory +cd src/frontend + +# Run Playwright tests +npx playwright test --ui tests/end-to-end + +# After the tests are finished, you can add cleanup or teardown logic here if needed + +# Terminate the background processes (backend and frontend) +pkill -f "make backend" +pkill -f "make frontend"