Socket
Book a DemoInstallSign in
Socket

ava-webcomponents

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ava-webcomponents

Utility middleware for testing web components in AVA via Puppeteer.

0.1.3
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

ava-webcomponents

Utility middleware for testing web components in AVA via Puppeteer.

Travis   npm   License MIT   code style: prettier

npm: npm install ava-webcomponents
yarn: yarn add ava-webcomponents

Getting Started

Create a file that renders content to the screen – such as a web component:

class Hello extends HTMLElement {
    connectedCallback() {
        this.innerHTML = 'Hello AVA!';
    }
}

customElements.define('x-ava', Hello);

Use ava-webcomponents to import the file in your AVA test, which then gives you access to the Puppeteer page variable, as well as a util function for awaiting upgrade of a defined web component.

All imports in your web component file will be resolved relative to the nearest package.json file, which uses a simple Express server instance to import your files.

import test from 'ava';
import withComponent from 'ava-webcomponents';

test(
    'It should render "Hello AVA!";',
    withComponent(`${__dirname}/helpers/example.js`),
    async (t, { page, utils }) => {
        await utils.waitForUpgrade('x-ava');

        const content = await page.evaluate(() => {
            const node = document.createElement('x-ava');
            document.body.append(node);
            return node.innerHTML;
        });

        t.is(content, 'Hello AVA!');
    }
);

With the second argument of the withComponent function you can pass options for puppeteer.launch. However there's also a shortcut for debugging Puppeteer by using withComponent.debug which slows down the tests, opens the devtools, and prevents Chromium from being headless.

FAQs

Package last updated on 06 Apr 2019

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.