Update Playwright + Use Nix (#311)

* use nix for execution

* update setup instructions

* headless

* headless via xvfb-run
This commit is contained in:
Simon Gardling
2025-08-21 15:43:17 -07:00
committed by GitHub
parent ad3b215dbc
commit ad2e0b8bb3
4 changed files with 117 additions and 5 deletions

View File

@@ -5,11 +5,19 @@ Under development, however mainly for personal use!
## How to setup ##
1. Download or clone source code
2. Run `npm i` to install the packages
3. Change `accounts.example.json` to `accounts.json` and add your account details
4. Change `config.json` to your liking
5. Run `npm run build` to build the script
6. Run `npm run start` to start the built script
2. Change `accounts.example.json` to `accounts.json` and add your account details
3. Change `config.json` to your liking
4. Either go the nix or non-nix route
### How to setup (not with nix) ###
5. Run `npm i` to install the packages
6. Run `npm run build` to build the script
7. Run `npm run start` to start the built script
### How to setup (with nix) ##
5. Get [Nix](https://nixos.org/)
6. Run `./run.sh`
7. That's it!
## Notes ##
- If you end the script without closing the browser window first (only with headless as false), you'll be left with hanging chrome instances using resources. Use taskmanager to kill these or use the included `npm run kill-chrome-win` script. (Windows)

61
flake.lock generated Normal file
View File

@@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1749727998,
"narHash": "sha256-mHv/yeUbmL91/TvV95p+mBVahm9mdQMJoqaTVTALaFw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "fd487183437963a59ba763c0cc4f27e3447dd6dd",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-25.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

40
flake.nix Normal file
View File

@@ -0,0 +1,40 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
flake-utils = {
url = "github:numtide/flake-utils";
};
};
outputs =
{ nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
};
in
{
devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
nodejs
playwright-driver.browsers
typescript
playwright-test
# fixes "waiting until load" issue compared to
# setting headless in config.json
xvfb-run
];
shellHook = ''
export PLAYWRIGHT_BROWSERS_PATH=${pkgs.playwright-driver.browsers}
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true
npm i
npm run build
'';
};
}
);
}

3
run.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
nix develop --command bash -c "xvfb-run npm run start"