npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@eyeo/get-browser-binary

v0.17.0

Published

Install browser binaries and matching webdrivers

Downloads

16,817

Readme

get-browser-binary

Install specific browser versions for Chromium, Firefox and Edge, and their matching selenium webdriver.

Getting started

The sample below shows how to install the latest Chromium and run it using selenium webdriver:

import {BROWSERS} from "@eyeo/get-browser-binary";

(async function example() {
  let {binary} = await BROWSERS.chromium.installBrowser("latest");
  console.log(`Chromium executable location: ${binary}`);

  let driver = await BROWSERS.chromium.getDriver("latest");
  await driver.navigate().to("https://example.com/");
  await driver.quit();
})();

test/browsers.js provides other usage examples of the library.

For more information, please refer to the API documention. If you are already on the documentation page, you may find the API contents on the right side.

Supported browser versions

  • Chromium >= 77 (Chromium ARM >= 92)
  • Firefox >= 68
  • Edge >= 95 (Windows Edge >= 79)

Note: Installing Edge is not supported on Windows. It is assumed to be installed because it is the default browser on that platform. On macOS, only the latest Edge version is supported.

Verbose logging

Set the VERBOSE environment variable to "true" to get verbose logging on download requests.

Offline execution

It is possible to run browsers offline as long as they have been previously installed. Example:

// Online
let {binary} = await BROWSERS[browser].installBrowser(version);
console.log(binary); // keep the browser binary location to use it offline
let driver = await BROWSERS[browser].getDriver(version); // let the driver binary download

// Offline
let customBrowserBinary = "<browser binary location>";
let driver = await BROWSERS[browser].getDriver(version, {customBrowserBinary});

Development

Prerequisites

  • Node >= 18
  • npm >= 9

Installing/Updating dependencies

npm install

Folders to ignore / cache

All browser and webdriver files will be extracted to the ./browser-snapshots folder, which probably makes sense to be ignored (for instance, by adding it to .gitignore).

On the other hand, ./browser-snapshots/<browser_name>/cache will hold all the downloaded installation files required by <browser_name>. Therefore, it may be useful to add ./browser-snapshots/*/cache to the list of cached folders in your CI pipeline configuration.

Testing

Running all tests:

npm test

Options

The grep option filters the tests to run with a regular expression. Example:

npm test -- --grep "chromium.*latest"

The timeout option overrides the timeout defined by .mocharc.json. Increasing the timeout may be useful on slow connection environments:

npm test -- --timeout <ms>

By default, tests delete the ./browser-snapshots before each Browser suite runs. To change that behavior you may set the TEST_KEEP_SNAPSHOTS environment variable to true. Example:

TEST_KEEP_SNAPSHOTS=true npm test

Test server

Tests use a local http server, which is managed by the npm test command. If needed, the test server can also run independently:

npm run test-server

Then tests may be executed on a separate session. Example:

npm run test-suite -- --grep "chromium.*latest"

Running tests on Docker

Useful to reproduce the CI environment of the test:browsers:linux job.

Intel/AMD architecture

docker build -f test/docker/Dockerfile -t browsers .
docker run --shm-size=512m -it browsers

The grep and timeout options can also be used on Docker via the TEST_ARGS parameter:

docker run --shm-size=512m -e TEST_ARGS="--grep chromium.*latest --timeout 100000" -it browsers

ARM architecture (M1/M2 Apple Silicon)

The run is done emulating the AMD architecture. Requirements:

  • macOS >= 13 (Ventura)
  • Rosetta
  • The feature "Use Rosetta for x86/amd64 emulation on Apple Silicon" enabled in Docker

The --platform option should be used when running the image:

docker run --platform linux/amd64 --shm-size=512m -e TEST_ARGS="--grep chromium.*latest" -it browsers

Building the documentation

npm run docs

Code of Conduct

All contributors to this project are required to read and follow our code of conduct.