diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index e706c7e..5e73985 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -17,11 +17,10 @@ jobs: run: npm ci - name: Install Playwright Browsers run: npx playwright install --with-deps - - name: Set environment variables from JSON - run: | - echo "${{ secrets.SECRETS_JSON }}" > secrets.json - cat secrets.json | jq -r 'to_entries | .[] | "echo \(.key)=\(.value) >> $GITHUB_ENV"' | sh - name: Run Playwright tests + env: + SWAG_LABS_USERNAME: ${{ secrets.SWAG_LABS_USERNAME }} + SWAG_LABS_PASSWORD: ${{ secrets.SWAG_LABS_PASSWORD }} run: npx playwright test - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} diff --git a/tests/e2e/ui-tests/swag-labs/swg-login-form.spec.js b/tests/e2e/ui-tests/swag-labs/swg-login-form.spec.js index 1441fa3..393a7d7 100644 --- a/tests/e2e/ui-tests/swag-labs/swg-login-form.spec.js +++ b/tests/e2e/ui-tests/swag-labs/swg-login-form.spec.js @@ -1,8 +1,8 @@ import { test } from '@playwright/test'; import { SwagLabsDevPage } from '../../../pages/swag-labs-dev-page'; -import loadEnv from '../../../helpers/loadEnv'; +import dotenv from 'dotenv'; -loadEnv(); +dotenv.config({ path: '.env' }); test.beforeEach('goto baseURL', async ({ page }) => { const swagLabsBaseURL = new SwagLabsDevPage(page); diff --git a/tests/helpers/loadEnv.js b/tests/helpers/loadEnv.js deleted file mode 100644 index e8225aa..0000000 --- a/tests/helpers/loadEnv.js +++ /dev/null @@ -1,28 +0,0 @@ -const dotenv = require('dotenv'); -const fs = require('fs'); -const path = require('path'); - -function loadEnv() { - const envPath = path.resolve(__dirname, '../../.env'); - if (fs.existsSync(envPath)) { - dotenv.config({ path: envPath }); - } else { - const secretsPath = path.resolve(__dirname, '../../secrets.json'); - if (fs.existsSync(secretsPath)) { - const secrets = JSON.parse(fs.readFileSync(secretsPath, 'utf8')); - for (const [key, value] of Object.entries(secrets)) { - process.env[key] = value; - } - } else { - const secretsJson = process.env.SECRETS_JSON; - if (secretsJson) { - const envConfig = JSON.parse(secretsJson); - for (const [key, value] of Object.entries(envConfig)) { - process.env[key] = value; - } - } - } - } -} - -module.exports = loadEnv; \ No newline at end of file