Skip to content

Commit 1092d77

Browse files
authored
Merge pull request #825 from cisagov/Playwright_local_testing_changes
Change Playwright configuration to have test domain as an environment variable
2 parents ce88057 + cc177e2 commit 1092d77

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

dev.env.example

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ IS_DMZ=1
137137
POSTGRES_SCAN_USER=
138138
POSTGRES_SCAN_PASSWORD=
139139

140-
PW_XFD_URL = 'http://xfd-frontend-1:3000/'
141-
PW_XFD_USERNAME = '[email protected]'
142-
PW_XFD_PASSWORD =
143-
PW_XFD_2FA_ISSUER =
144-
PW_XFD_2FA_SECRET =
145-
PW_XFD_USER_ROLE =
146-
SESSION_STORAGE = ""
140+
PW_XFD_URL='http://xfd-frontend-1:3000/'
141+
PW_XFD_USERNAME='[email protected]'
142+
PW_XFD_PASSWORD=
143+
PW_XFD_2FA_ISSUER=
144+
PW_XFD_2FA_SECRET=
145+
PW_XFD_USER_ROLE=
146+
SESSION_STORAGE= ""

playwright/global-setup.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ let totp = new OTPAuth.TOTP({
1818
const axios = require('axios');
1919

2020
const waitForFrontend = async (url, timeout = 900000, checkInterval = 5000) => {
21+
console.log(`Url: ${url}`);
2122
const startTime = Date.now();
2223
while (Date.now() - startTime < timeout) {
2324
try {
@@ -48,8 +49,8 @@ async function globalSetup(config: FullConfig) {
4849
const page = await browser.newPage();
4950

5051
//Log in with credentials.
51-
await waitForFrontend('http://xfd-frontend-1:3000');
52-
await page.goto('http://xfd-frontend-1:3000');
52+
await waitForFrontend(process.env.PW_XFD_URL);
53+
await page.goto(String(process.env.PW_XFD_URL));
5354
await page.getByTestId('button').click();
5455
await page
5556
.getByLabel('Username (Email)')

playwright/playwright.config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ export default defineConfig({
2727
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
2828
reporter: [
2929
['list', { printSteps: true }],
30-
['json', { outputFile: 'test-results/test-results.json' }],
31-
['html', { open: 'always' }]
30+
['json', { outputFile: 'playwright-report/results.json' }],
31+
['html', { outputFolder: 'playwright-report/html', open: 'never' }]
3232
],
3333
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
3434
use: {
3535
/* Base URL to use in actions like `await page.goto('/')`. */
36-
baseURL: 'http://xfd-frontend-1:3000',
36+
baseURL: process.env.PW_XFD_URL,
37+
headless: true,
3738
storageState: 'storageState.json',
3839

3940
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */

0 commit comments

Comments
 (0)