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.22k stars 3.62k forks source link

[Feature]: apply $SHELL env variable at playwright test command. #33020

Open ytw0728 opened 3 days ago

ytw0728 commented 3 days ago

🚀 Feature Request

Hello, always thank you for all your efforts and this awesome project.

I'd like to say that "playwright test" command needs to apply the user's default shell.

For now, "playwright test" launches a child process by node:child_process spawn with "shell:true" option though. As you know, node:child_process.spawn always executes via /bin/sh on UNIX platform with "shell:true" option. (https://nodejs.org/api/child_process.html#child_processspawncommand-args-options)

So, if it's safe and okay, I want to suggest that to pass process.env.SHELL variable to child_process.spawn's shell option.

Example

https://github.com/microsoft/playwright/blob/dbe881cfdc0e4a7f42442b8244c6d5ee2d607e82/packages/playwright/src/plugins/webServerPlugin.ts#L104

as-is

      shell: true,

to-be

      shell: process.env.SHELL, // if it's on windows, process.env.ComSpec

Motivation

This would be helpful to "Playwright Testing for VSCode" extension users who use environment setup tools (like asdf, mise-en-place, nvm, etc)

Because "Playwright Testing for VSCode" is given environment variables of the system when the extension is activated. At that moment the cwd is root (/), so if that user is using environment setup tools, those given variables could be insufficient.

Passing the default shell info to child_process would help to apply the right environment variables on a project path.

Thanks!

pavelfeldman commented 2 days ago

Could you provide an example of a problem? Also note that there is a way to set up Playwright environment in VS Code:

Image