Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error: getaddrinfo ENOTFOUND "url" with baseUrl in playwright-ct.config.ts #27627

Closed
Crone1331 opened this issue Oct 16, 2023 · 1 comment · Fixed by #27689
Closed

[BUG] Error: getaddrinfo ENOTFOUND "url" with baseUrl in playwright-ct.config.ts #27627

Crone1331 opened this issue Oct 16, 2023 · 1 comment · Fixed by #27689

Comments

@Crone1331
Copy link

System info

  • Playwright Version: [v1.39.0]
  • Operating System: [Ubuntu 20]
  • Browser: [All]
  • Other info:

Source code

Config file

// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
    updateSnapshots: process.env.updateSnapshots as TUpdateSnapshots || 'missing',
    testDir: process.env.visualTestPath,
    timeout: 10 * 1000,
    fullyParallel: false,
    retries: 1,
    workers: 1,
    use: {
        baseURL: process.env.CI_ENVIRONMENT_URL || 'http://localhost:8080/',
    },
    projects: [
        {
            name: 'chromium',
            use: {...devices['Desktop Chrome']},
        },
    ],
});

Test file (self-contained)

import {
    test,
    expect,
    devices,
} from 'playwright/test';

test.describe('Visual test', (): void => {
    const provider: string = process.env.visualTestProvider as string;
    const theme: string = process.env.visualTestTheme as string;

    test.beforeEach(async ({page}): Promise<void> => {
        await page.goto('http://localhost:8080/', {waitUntil: 'networkidle'});
        await page.waitForSelector('.root');
    });
});

Steps

  • [Run the test]
  • [...]
  • [Get error =( ]

Expected

Currect work

Actual

Error: getaddrinfo ENOTFOUND http://localhost:8080/

Note

When running tests, if use.baseURL is specified in playwright-tc.config.ts, the error Error is thrown: getaddrinfo ENOTFOUND http://localhost:8080/
If you remove the baseUrl, there is no error

@Crone1331 Crone1331 changed the title [BUG] Error: getaddrinfo ENOTFOUND http://localhost:8080/ with baseUrl in playwright-ct.config.ts [BUG] Error: getaddrinfo ENOTFOUND "url" with baseUrl in playwright-ct.config.ts Oct 16, 2023
@mxschmitt
Copy link
Member

mxschmitt commented Oct 16, 2023

I was able to reproduce it with the following diff:

diff --git a/tests/components/ct-react-vite/playwright.config.ts b/tests/components/ct-react-vite/playwright.config.ts
index 63d909ae2..50bcb1899 100644
--- a/tests/components/ct-react-vite/playwright.config.ts
+++ b/tests/components/ct-react-vite/playwright.config.ts
@@ -38,7 +38,10 @@ export default defineConfig({
   projects: [
     {
       name: 'chromium',
-      use: { ...devices['Desktop Chrome'] },
+      use: {
+        ...devices['Desktop Chrome'],
+        baseURL: process.env.CI_ENVIRONMENT_URL || 'http://localhost:8080/',
+      },
     },
     {
       name: 'firefox',

with:

DEBUG=pw:test* npx playwright test --config playwright.config.ts in tests/components/ct-react-vite.

bug is around here:

const port = use.ctPort || 3100;
const host = use.baseURL || 'localhost';

image

cc @sand4rt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants