playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Bug]: Playwright Test for VSCode not always running global setup

Open twalshOG opened this issue 1 year ago • 3 comments
trafficstars

Version

1.46.0

Steps to reproduce

  1. Install VS Code and add the Playwright Test for VSCode extension.
  2. Clone https://github.com/twalshOG/PlaywrightBug
  3. Run the test (this project only has one test for simplicity sake) from the Playwright test explorer image
    Note that global setup ran
    image
  4. Run the test again via the test explorer image
    Note that global setup did not run

Expected behavior

I would expect global setup to run each time I run

Actual behavior

Global setup not running on subsequent runs when tests are run via the Playwright test extension for VS Code.

Additional context

Work arounds

  1. Close and reopen VS Code
  2. Manually trigger "Run global teardown" image
    This makes it so the next run will run global setup, but runs after that will continue to skip global setup.

Thoughts

  1. This look something was intentionally done
    1. If I am using my own test web service it stays up between runs
    2. The SETUP section of the TESTING: PLAYWRIGHT VSCode bar disables Run global setup and enables Run global teardown.
  2. Within many contexts this would work great, however it gets really unpleasant when trying to update/debug global setup

Recommendations

  1. Document when global setup/teardown should be/will be executed when using VSCode
  2. Add a setting that allows users to decide if they want to use the same global setup between test runs image

Environment

System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M1 Max
    Memory: 195.63 MB / 32.00 GB
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    Yarn: 1.22.21 - /opt/homebrew/bin/yarn
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
  IDEs:
    VSCode: 1.92.0 - /opt/homebrew/bin/code
  Languages:
    Bash: 3.2.57 - /bin/bash
  npmPackages:
    @playwright/test: ^1.46.0 => 1.46.0 
  Test extension:
    Playwright Test for VSCode: v1.1.7

twalshOG avatar Aug 12 '24 14:08 twalshOG

Looks like this is likely related to #32103

twalshOG avatar Aug 12 '24 14:08 twalshOG

A setting makes sense to me.

pavelfeldman avatar Aug 12 '24 20:08 pavelfeldman

Would such a setting also result in globalTeardown being ran after each test run? Right now it seems like it's never ran, which means you can end up with stale state that isn't cleaned up.

Charles-Gagnon avatar Aug 12 '24 20:08 Charles-Gagnon