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

[Regression]: VSCode extension uses workspace root instead of location config as CWD #30796

Closed
pietdevries94 opened this issue May 14, 2024 · 5 comments
Assignees

Comments

@pietdevries94
Copy link

Last Good Version

1.0.22

First Bad Version

1.1.1

Steps to reproduce

  1. Clone my repo at https://github.com/pietdevries94/playwright-vs-code-reproduction
  2. npm install
  3. use the vscode extension to run the test case in the repo

Expected behavior

the test works, because the cwd contains the string subfolder

Actual behavior

the test fails because it runs in the workspace root

Additional context

No response

Environment

System:
    OS: Linux 6.1 NixOS 23.11 (Tapir) 23.11 (Tapir)
    CPU: (16) x64 AMD Ryzen 9 5900HX with Radeon Graphics
    Memory: 11.29 GB / 27.27 GB
    Container: Yes
  Binaries:
    Node: 20.12.2 - /nix/store/71r8n7ckcpvav9qwshlr12hjd5nlchds-nodejs-20.12.2/bin/node
    npm: 10.5.0 - /nix/store/71r8n7ckcpvav9qwshlr12hjd5nlchds-nodejs-20.12.2/bin/npm
    pnpm: 8.15.5 - /nix/store/16s3dlkk4n6h9nh6mfp77fcm6gll0m5l-pnpm-8.15.5/bin/pnpm
  IDEs:
    VSCode: 1.89.1 - /etc/profiles/per-user/piet/bin/code
  Languages:
    Bash: 5.2.26 - /nix/store/h3bhzvz9ipglcybbcvkxvm4vg9lwvqg4-bash-5.2p26/bin/bash
  npmPackages:
    @playwright/test: ^1.44.0 => 1.44.0
@pavelfeldman
Copy link
Member

It seems that the test that asserts the cwd breaks as it relies on cwd being the config dir. I can confirm that there has been a change in behavior to make tests start with the workspace as cwd. Our expectations are that tests don't rely on the folder they were started from, so I would recommend to never rely on cwd and use __dirname / path.resolve instead.

@UncleGus
Copy link

I have a similar issue. My playwright setup is in a subfolder of the main app project, and there is a subfolder under that called data which contains a CSV file that is read in and parsed by the test. In the latest version, it now reports the error:
Error: ENOENT: no such file or directory, open 'c:\Users\<me>\Projects\<project root>\data\OtherContents.csv' whereas the file is actually found in c:\Users\<me>\Projects\<project root>\apps\playwright\data\OtherContents.csv. When running the tests, everything works as expected. When I roll the playwright extension back to 1.0.22, the error disappears.

@pavelfeldman
Copy link
Member

@UncleGus: You are probably using fs.readFile API with a relative name, also a no-no in testing. If you run your tests from command line from a different folder, it'll also fall apart.

@pietdevries94
Copy link
Author

I used cwd in the test as a quick way to show the issue. We have/had the same issue as @UncleGus where we used a relative path. In hind sight, you are right it's not correct, but that does not takeaway that this is a regression, where other people may be affected.

We used path.resolve and __dirname to fix this issue for our situation

@pavelfeldman
Copy link
Member

Closing as per above, please feel free to open a new issue if this does not cover your use case.

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

No branches or pull requests

4 participants