Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@web/test-runner-chrome

Package Overview
Dependencies
Maintainers
6
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web/test-runner-chrome

Chrome browser launcher for Web Test Runner

  • 0.5.12
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
69K
Maintainers
6
Weekly downloads
 
Created
Source

Web Test Runner Chrome

Browser launcher for @web/test-runner. Looks for a locally installed instance of Chrome, and controls it using puppeteer-core. This avoids the postinstall step of puppeteer or playwright, speeding up installation of projects.

If you don't want to install Chrome globally, for example in a CI environment, you can use @web/test-runner-puppeeteer or @web/test-runner-playwright

See @web/test-runner for a default implementation and CLI for the test runner.

Usage

If you are using @web/test-runner, the chrome launcher is used by default. You can instantiate it yourself from the config to use on the advanced options.

Customizing launcher options

If you want to customize the puppeteer launcher options, you can add the browser launcher in the config.

You can find all possible launch options in the official documentation

const { chromeLauncher } = require('@web/test-runner-chrome');

module.exports = {
  browsers: [
    chromeLauncher({
      launchOptions: {
        headless: false,
        args: ['--some-flag'],
      },
    }),
  ],
};

Customizing page creation

You can use a custom function to create the puppeteer Page. You can use this for example to set up injecting scripts for environment variables or to expose functions to the browser to control the page.

const { chromeLauncher } = require('@web/test-runner-chrome');

module.exports = {
  browsers: [
    chromeLauncher({
      async createPage({ browser, config }) {
        const page = await browser.newPage();

        // expose websocket endpoint as an environment variable in the browser
        page.evaluateOnNewDocument(wsEndpoint => {
          window.__ENV__ = { wsEndpoint };
        }, browser.wsEndpoint());

        // expose a function in the browser, which calls a function on the
        // puppeteer page in NodeJS
        page.exposeFunction('puppeteerBringToFront', () => {
          page.bringToFront();
        });

        return page;
      },
    }),
  ],
};

Keywords

FAQs

Package last updated on 27 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc