sveltejs / cli

The Svelte CLI
MIT License
267 stars 13 forks source link

When installing Playwright from the SvelteKit installer, it should offer to install the browsers #316

Open unikitty37 opened 1 year ago

unikitty37 commented 1 year ago

Describe the problem

When I tried to run Playwright tests, they failed because the browsers were not installed. As Playwright isn't much use without them, it would be useful for the installer to run npx playwright install after installing Playwright.

Describe the proposed solution

If the user opts to install Playwright, the next question should be whether or not to install all the Playwright browsers. The default should be "yes" — if the user only wants to install selected browsers, they can choose "no" and then install the browsers manually.

Alternatives considered

Typing npx playwright install after trying to run tests and having them fail to find a browser.

Importance

nice to have

Additional Information

Usually, you're not in a state to run npx playwright test until you're a fair way into the project, at which point you've forgotten that it didn't install the browsers at the same time as Playwright.

As Playwright installs its browsers per-user, not per-project (in ~/Library/Caches/ms-playwright on macOS) this doesn't affect anyone who's already installed the browsers as part of a previous project. I suspect most of the SvelteKit devs fall into this camp, which might be why nobody's noticed this 😁

Conduitry commented 1 year ago

I'm not sure how helpful this would be, as anyone else who clones the generated repo afterwards won't then automatically get the browsers (and their dependencies) installed.

On Linux at least, there's also npx playwright install-deps that also needs to be run (once), which requires sudo. I don't think we'd want to automatically install the browsers without their dependencies, and I don't think we'd want to run something that is going to present a sudo prompt.

unikitty37 commented 1 year ago

I didn't realise there was a sudo requirement on Linux. That wouldn't be ideal.

Would it be reasonable to output a warning that the user should run npx playwright install themselves? (Presumably running that warns about needing to install dependencies on Linux…)

ghostdevv commented 1 year ago

Would it be reasonable to output a warning that the user should run npx playwright install themselves? (Presumably running that warns about needing to install dependencies on Linux…)

It might be nice to do this, or even add it into the generated README (if it's not there already)

On Linux at least, there's also npx playwright install-deps that also needs to be run (once), which requires sudo. I don't think we'd want to automatically install the browsers without their dependencies, and I don't think we'd want to run something that is going to present a sudo prompt.

Building on that, npx playwright install-deps only works on ubuntu (iirc) so if we did do it we would need some os checks which sounds quite messy