Browse Source

run the tests on a different port (so there's no conflict when running the development server)

master
Trent Larson 1 week ago
parent
commit
5f39beef55
  1. 6
      playwright.config-local.ts
  2. 9
      test-playwright/40-add-contact.spec.ts

6
playwright.config-local.ts

@ -25,7 +25,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://localhost:8080",
baseURL: "http://localhost:8081",
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
@ -91,8 +91,8 @@ export default defineConfig({
*/
webServer: {
command:
"VITE_APP_SERVER=http://localhost:8080 VITE_DEFAULT_ENDORSER_API_SERVER=http://localhost:3000 VITE_PASSKEYS_ENABLED=true npm run dev",
url: "http://localhost:8080",
"VITE_APP_SERVER=http://localhost:8081 VITE_DEFAULT_ENDORSER_API_SERVER=http://localhost:3000 VITE_PASSKEYS_ENABLED=true npm run dev -- --port=8081",
url: "http://localhost:8081",
reuseExistingServer: !process.env.CI,
},
});

9
test-playwright/40-add-contact.spec.ts

@ -200,7 +200,7 @@ test('Add contact, copy details, delete, and import from paste & from file', asy
});
test('Copy contact to clipboard, then import ', async ({ page, context }) => {
test('Copy contact to clipboard, then import ', async ({ page, context }, testInfo) => {
await importUser(page, '00');
await page.goto('./account');
@ -244,7 +244,12 @@ test('Copy contact to clipboard, then import ', async ({ page, context }) => {
const clipboardText = await page.evaluate(async () => {
return navigator.clipboard.readText();
});
const PATH_PART = "http://localhost:8080/contact-import/";
// look into the playwright.config file for the server URL
const webServer = testInfo.config.webServer;
const clientServerUrl = webServer?.url;
const PATH_PART = clientServerUrl + "/contact-import/";
expect(clipboardText).toContain(PATH_PART);
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss alert

Loading…
Cancel
Save