let pkgs = import <nixpkgs> {};
in
pkgs.buildFHSEnv {
name = "playwright";
targetPkgs = pkgs: with pkgs; [
# playwright (chrome headless = false works)
openssl
systemd
glibc glibc.dev
glib
cups.lib cups
nss
nssTools
alsa-lib
dbus
at-spi2-core
libdrm
expat
xorg.libX11
xorg.libXcomposite
xorg.libXdamage
xorg.libXext
xorg.libXfixes
xorg.libXrandr
xorg.libxcb
mesa
libxkbcommon
pango
cairo
nspr
];
profile = ''
export LD_LIBRARY_PATH=/run/opengl-driver/lib:/run/opengl-driver-32/lib:/lib
export FONTCONFIG_FILE=/etc/fonts/fonts.conf
'';
runScript = pkgs.writeShellScript "wrapper" ''
exec ${pkgs.zsh}/bin/zsh
'';
# As intended by this bubble wrap, share as much namespaces as possible with user.
unshareUser = false;
unshareIpc = false;
unsharePid = false;
unshareNet = false;
unshareUts = false;
unshareCgroup = false;
# Since "insync start" command starts a daemon, this daemon should die with it.
dieWithParent = true;
}
nix-build (nixpkgs-23.11) then chroot. Then simple test
import { chromium, devices } from 'playwright';
import assert from 'node:assert';
(async () => {
// Setup
const browser = await chromium.launch({ headless: false });
const context = await browser.newContext(devices['iPhone 11']);
const page = await context.newPage();
// The actual interesting bit
await context.route('**.jpg', route => route.abort());
console.log(1);
await page.goto('https://example.com/');
console.log(2);
const pt = await page.title()
console.log("page title");
console.log(JSON.stringify(pt));
assert(pt === 'Example Domain'); // 👎 not a Web First assertion
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms))
await sleep(5000)
// Teardown
await context.close();
await browser.close();
})();
with chrome worked with the npx playwright install command meaning you can use the version the project was tested with.