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

@ivanpadavan/karma-playwright-launcher

v0.4.1

Published

Karma launcher plugin powered by playwright.

Downloads

31

Readme

karma-playwright-launcher

Build status: Playwright (MacOS) Build status: Playwright (Ubuntu) Build status: Playwright (Windows) NPM version

Provides six browsers to Karma:

  • Chromium
  • ChromiumHeadless
  • Firefox
  • FirefoxHeadless
  • WebKit
  • WebKitHeadless

Powered by Playwright.

Use Playwright capabilities within your test

You may need to use Playwright capabilities right within sandboxed javascript code. That can be achieved using exposeBinding API.

You can pass callbacks that will be available within your tests by providing bindings object. The one from example is accessable by default.

In karma.conf.js:

    ...
    customLaunchers: {
        WebkitClickablr: {
            base: 'Webkit',
            bindings: {
                click: ({ frame }, selector) => frame.locator(selector).click()
            }
        }
    },
    ...

In spec file:

...
document.body.addEventListener('click', (event) => {
    expect(event.isTrusted).toBeTruthy();
    done();
})
click('body');
...

Device emulation

Playwright supports device emulation to control various aspects of the browser. This is probably more important for E2E testing than unit testing, but some configuration (like locale and timezone) may be useful for unit testing as well.

You can control these settings by providing device and/or contextOptions in karma.conf.js.

    ...
    customLaunchers: {
        iPhone: {
            base: 'Webkit',
            displayName: 'iPhone',
            device: 'iPhone 6',
            contextOptions: {
                locale: 'sv-SE'
            }
        }
    },

    browsers: [
        'iPhone',
    ],
    ...

Non-bundled browsers

The "real" Chrome, Edge or custom versions of the browsers can be configured by providing launchOptions in your Karma configuration. The browsers must be downloaded and installed manually.

    ...
    customLaunchers: {
        EdgeHeadless: {
            base: 'ChromiumHeadless',
            displayName: 'EdgeHeadless',
            launchOptions: {
                channel: 'msedge'
            }
        }
    },

    browsers: [
        'ChromiumHeadless',
        'EdgeHeadless',
        'FirefoxHeadless',
        'WebKitHeadless',
    ],
    ...

Valid values for the channel option are: chrome, chrome-beta, chrome-dev, chrome-canary, msedge, msedge-beta, msedge-dev, msedge-canary.

Older browsers

Each Playwright release bundles specific versions of Chromium, Firefox and WebKit. If you use Yarn or pnpm, it's possible you may lock the version of the playwright package in order to force a specific version. npm does not support this yet, but there is a package available that might work.

See the Playwright Release Notes for what browsers are bundled.

History

0.4.0

  • Ivan Frolkin: Add bindings and tests.

0.3.0

  • Martin Blom: Now uses the Karma decorators and event handling instead of a custom class.

0.2.1

  • Martin Blom: Fixed typo. Bumped rev.

0.2.0

  • Martin Blom: Publish forked package as @onslip/karma-playwright-launcher.
  • Martin Blom: Added device emulation support.

0.1.1

  • Martin Blom: Relaxed required playwright version and added note about pinning.

0.1.0

  • Martin Blom: Provide both headful and headless browsers, support custom launch options.
  • Emil Björklund: Add guard for missing browser.

0.0.1

  • Joel Einbinder/Endy Jasmi: Original version, published as karma-playwright-launcher.