Playwright: Difference between revisions
imported>Pbek m Fix grammar |
imported>Pbek Mention vscode |
||
Line 5: | Line 5: | ||
</syntaxHighlight> | </syntaxHighlight> | ||
You can for example put this <code>shell.nix</code> in the directory with your playwright tests: | |||
<syntaxHighlight lang=nix> | <syntaxHighlight lang=nix> | ||
Line 11: | Line 11: | ||
pkgs.mkShell { | pkgs.mkShell { | ||
nativeBuildInputs = with pkgs; [ | nativeBuildInputs = with pkgs; [ | ||
vscode | |||
playwright-driver.browsers | playwright-driver.browsers | ||
]; | ]; | ||
Line 20: | Line 21: | ||
} | } | ||
</syntaxHighlight> | </syntaxHighlight> | ||
You can then just run <code>nix-shell --run "code ."</code> to open Visual Studio Code in that directory. | |||
Don't forget to install the <code>Playwright Test for VSCode</code> extension in Visual Studio Code. | |||
Then you should be able to run your tests in Visual Studio Code. |
Revision as of 09:11, 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
You can for example put this shell.nix
in the directory with your playwright tests:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
vscode
playwright-driver.browsers
];
shellHook = ''
export PLAYWRIGHT_BROWSERS_PATH=${pkgs.playwright-driver.browsers}
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true
'';
}
You can then just run nix-shell --run "code ."
to open Visual Studio Code in that directory.
Don't forget to install the Playwright Test for VSCode
extension in Visual Studio Code.
Then you should be able to run your tests in Visual Studio Code.