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]: Overwriting .env files interrupts tests when using the VSCode Playwright extension #34344

Open
jaktestowac opened this issue Jan 15, 2025 · 0 comments
Assignees
Labels

Comments

@jaktestowac
Copy link
Contributor

Version

1.49.1

Steps to reproduce

Start new project ( I use Windows 11 machine) with:
npm init playwright@latest --yes '--' '--quiet' '--browser=chromium'

Make sure that you have Playwright Extension installed (tested on Playwright Test for VSCode v1.1.12)

Add test:

import { expect, test } from '@playwright/test';
import * as fs from 'fs';

test('test broken plugin', async ({ page }) => {
  fs.writeFileSync('.env', '');

  console.log('Go to website');
  await page.goto('http://playwright.dev');

  console.log('Do the stuff');
  await expect(page.getByText('playwright').first()).toBeInViewport();
});

Run test form VSCode using Playwright Test for VSCode extension:

Image

Expected behavior

Test should finish successfully, like when commenting line: fs.writeFileSync('.env', '');

Image

Actual behavior

Test is interrupted:

Image

Additional context

  1. Running tests in the console works fine:

    Running tests in console

  2. Renaming the file so it no longer matches the **.env* pattern
    If you rename the file so it does not match the **.env* pattern (e.g., .my-env), the test passes when triggered from VSCode with the Playwright extension.

    This issue is likely related to the watcher implementation in the VSCode Playwright extension:
    Source code reference
    Introduced in this PR:
    #403

  3. Why does this scenario matter?

    • Using dotenv allows you to override .env files and reload them at runtime.
    • However, when the Playwright extension in VSCode watches files matching **.env*, it prevents this behavior, creating a big inconsistency compared to running tests from the terminal.

Environment

VSCode with Playwright Test for VSCode v1.1.12
System:
    OS: Windows 11
    CPU: (16) x64 11th Gen Intel(R) Core(TM)
    Memory: 43.39 GB / 63.71 GB
  Binaries:
    Node: 20.11.0 - \nodejs\node.EXE
    npm: 10.4.0 - \nodejs\npm.CMD
  IDEs:
    VSCode: 1.95.3 - \Microsoft VS Code\bin\code.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
  npmPackages:
    @playwright/test: ^1.49.0
@jaktestowac jaktestowac changed the title [Bug]: [Bug]: Overwriting .env files interrupts tests when using the VSCode Playwright extension Jan 15, 2025
@yury-s yury-s added the v1.51 label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants