Playwright: Difference between revisions
imported>Pbek m Fix typos |
imported>Pbek Add shell.nix example |
||
Line 3: | Line 3: | ||
<syntaxHighlight lang=nix> | <syntaxHighlight lang=nix> | ||
export PLAYWRIGHT_BROWSERS_PATH=/path/to/drivers | export PLAYWRIGHT_BROWSERS_PATH=/path/to/drivers | ||
</syntaxHighlight> | |||
This `shell.nix` can serve as example: | |||
<syntaxHighlight lang=nix> | |||
{ pkgs ? import <nixpkgs> {} }: | |||
pkgs.mkShell { | |||
nativeBuildInputs = with pkgs; [ | |||
playwright-driver.browsers | |||
]; | |||
shellHook = '' | |||
export PLAYWRIGHT_BROWSERS_PATH=${pkgs.playwright-driver.browsers} | |||
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true | |||
''; | |||
} | |||
</syntaxHighlight> | </syntaxHighlight> |
Revision as of 08:51, 3 November 2023
Installing browsers for playwright under NixOS
Normally, at first run, playwright will tell you to run playwright install
. The purpose of this is to install browsers for you that it can then use for testing. The installation itself will technically work. Unfortunately, the installed browsers will not be suitable to be used inside NixOS. This is due to the fact that dependencies will not be at places where the browsers expect them to be. To mitigate this problem, nixpkgs has a package called playwright-driver.browsers
. Before you start your script, make sure to set
export PLAYWRIGHT_BROWSERS_PATH=/path/to/drivers
This `shell.nix` can serve as example:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
playwright-driver.browsers
];
shellHook = ''
export PLAYWRIGHT_BROWSERS_PATH=${pkgs.playwright-driver.browsers}
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true
'';
}