Skip to content

Commit

Permalink
Add usage docs for playwright feature
Browse files Browse the repository at this point in the history
  • Loading branch information
gma committed Nov 7, 2024
1 parent 9caf6e3 commit 0c49b05
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/playwright/NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
## Notes on usage

This feature has been written to speed up the installation of [Playwright] within your devcontainers.

Playwright is installed with `npm`, which means we need Node.js to be installed inside your devcontainer. You can achieve that by including these two features inside your `devcontainre.json` file:

```json
"features": {
...
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/gma/devcontainer-features/features/playwright:1": {},
...
},
```

While your devcontainer is building this feature will:

- Temporarily install the latest version of the `playwright` package
- Use Playwight to install any operating system dependencies required by the browers you want to use (i.e. it runs `npx playwright install-deps <browser>`)
- Setup a named volume called `playwright-browsers` that Playwright will (later) use when you actually install some browsers

By default the dependencies for Chromium are installed. If you'd like to specify different browsers you can so by setting the "browsers" option:

```json
...
"ghcr.io/gma/devcontainer-features/features/playwright:1": {
"browsers": "firefox chrome"
},
...
```

Once the container is running, you'll take care of installing Playwright in your application as normal, with a command like this:

```sh
npm install --save-dev playwright@<version>
```

Once you've installed Playwright into your project, you'll be able to install the browsers you want to use:

```sh
npx playwright install chromium
```

The `playwright install` command will store the downloaded Chromium files in `/playwright/browsers`, which is mounted as a Docker volume. They'll therefore persist if you delete and then restart the container, or rebuild the image.

[Playwright]: https://playwright.dev

0 comments on commit 0c49b05

Please sign in to comment.