Commit 682e3b71 authored by WxNzEMof's avatar WxNzEMof
Browse files

playwright-test: Add PLAYWRIGHT_BROWSERS_PATH to build environment

This allows writing self-contained node scripts (using a nix-shell
shebang), without requiring a separate shell.nix which sets
PLAYWRIGHT_BROWSERS_PATH to pkgs.playwright-driver.browsers.
parent 15571147
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
  makeFontsConf,
  makeWrapper,
  runCommand,
  writeText,
  cacert,
}:
let
@@ -191,9 +192,27 @@ let
      runHook postInstall
    '';

    setupHook = writeText "setupHook.sh" ''
      addBrowsersPath () {
        if [[ ! -v PLAYWRIGHT_BROWSERS_PATH ]] ; then
          export PLAYWRIGHT_BROWSERS_PATH="${playwright-core.passthru.browsers}"
        fi
      }

      addEnvHooks "$targetOffset" addBrowsersPath
    '';

    meta = playwright.meta // {
      mainProgram = "playwright";
    };

    passthru.tests.env = runCommand "playwright-core-env-test" {
      buildInputs = [
        nodejs
        playwright-core
        playwright-test
      ];
    } "node ${./test.js}";
  });

  browsers-mac = stdenv.mkDerivation {
+8 −0
Original line number Diff line number Diff line
const playwright = require('playwright');
const fs = require('fs');
playwright.chromium.launch()
    .then((browser) => {
        console.log('OK');
        fs.writeFileSync(process.env.out, '');
        process.exit(0);
    });