JSPM

@onslip/karma-playwright-launcher

0.3.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 598
  • Score
    100M100P100Q109974F
  • License MIT

Karma launcher plugin powered by playwright.

Package Exports

  • @onslip/karma-playwright-launcher
  • @onslip/karma-playwright-launcher/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@onslip/karma-playwright-launcher) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@onslip/karma-playwright-launcher

npm version

Provides six browsers to Karma:

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

Powered by Playwright.

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.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.