playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Bug]: UI doesn't call setup and passes incorrect outputDir

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

Version

1.46.1

Steps to reproduce

Note: the tests don't matter, it's purely a config & setup/teardown issue.

  1. Set globalSetup to a file which contains console.log("setup", config.projects[0].outputDir)
  2. Set globalTeardown to a file which contains console.log("teardown", config.projects[0].outputDir)
  3. Run playwright test --output blah and observe that setup and teardown were called and logged appropriately
  4. Run playwright test --output blah --ui and observe that setup was not called and teardown was called with the incorrect outputDir.

Expected behavior

When running in UI mode, I expected setup to be called before the test started and for the correct config value to be passed. And I expected teardown to be called with the correct config value.

Actual behavior

Setup was not called in UI mode and teardown was called with an incorrect (default) value.

Additional context

The last version where this worked correctly was 1.42. This has broken as of 1.43 and is still broken as of the latest at the time of writing 1.46.1.

Related to https://github.com/microsoft/playwright/issues/30886

Environment

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
    Memory: 10.74 GB / 15.95 GB
  Binaries:
    Node: 20.13.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.5.2 - C:\Program Files\nodejs\npm.CMD
  IDEs:
    VSCode: 1.92.2 - C:\Users\User\AppData\Local\Programs\Microsoft VS Code\bin\code.CMD
  Languages:
    Bash: 4.4.23 - C:\Program Files\Git\usr\bin\bash.EXE
  npmPackages:
    @playwright/test: ^1.43.0 => 1.43.0

CreativeTechGuy avatar Aug 26 '24 22:08 CreativeTechGuy

Cannot reproduce it with 1.46.1, global setup runs once before all tests and you can see it in the output panel (image), global teardown runs once when UI mode window is closed. Can you share full project where it is not working?

yury-s avatar Aug 27 '24 16:08 yury-s

I didn't know that button opened output. Okay so slight edit to the bug report then with that knowledge:

  • Previously (1.42 and lower) the setup output was written to the console where the playwright command was run, now it's written to the output tab of the playwright UI window.
  • And the output in that tab still shows the incorrect outputDir when logged.

Here's a repro repo: https://github.com/CreativeTechGuy/playwright-outputDir-repro

CreativeTechGuy avatar Aug 28 '24 05:08 CreativeTechGuy

Thanks for the repro, that helps! outputDir indeed seems to be incorrect in UI mode, I'm gonna write a fix for that.

Skn0tt avatar Aug 28 '24 06:08 Skn0tt