microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.74k stars 3.65k forks source link

[BUG] vscode extension uses a different node version #18397

Closed kedevked closed 2 years ago

kedevked commented 2 years ago

Context:

Code Snippet

 const rawResponse = await fetch("url")

Describe the bug

when I run the command npx playwright test my test passes because I am using node 18 that has fetch. But when I use the extension to run the spec it fails complaining that fetch is not defined

mxschmitt commented 2 years ago

We pick the node version from the PATH environment variable, so mostly likely vscode is not picking it up correctly or you rely on nvm etc. I recommend to check the PATH env var when vscode gets launched. I see you are using WSL, maybe you have it only installed it inside WSL but not on the host?

kedevked commented 2 years ago

I am using nvm. Since I do have the file .nvmrc in my repo, nvm update the node version to be 18 whenever I cd to the repo. However, the extension still picks the default version which is the 14 I guess. As a matter of fact when I run node --version within the path of the repo, it is 18

mxschmitt commented 2 years ago

By default NVM does not automatically activate the version configured inside the .nvmrc file. You need to manually "use it" by doing "nvm use".

How does VSCode pick it up in your scenario? Since either you modified the nvm auto-load config inside bashrc or you do manual "nvm use".

collinclarke commented 1 year ago

Can the playwright extension be reloaded to respect the current version of node rather than the path version when opening the project? Some of our developers open the project directly in VsCode and so there is no opportunity to "use" the project version before the extension is initialized. @mxschmitt

h0jeZvgoxFepBQ2C commented 11 months ago

Why is this closed, this should be open @kedevked