@domx/testutils

Common testing utility scripts.

Usage no npm install needed!

<script type="module">
  import domxTestutils from 'https://cdn.skypack.dev/@domx/testutils';
</script>

README

TestUtils · GitHub license Build Status Lines npm

Common testing utility scripts.

Installation

npm install @domx/testutils

fragment

The test fragment can be used to test HTML elements that need to be appended to the DOM.

@import {fixture, html} from  "@domx/testutils";

const el = fixture(html`<my-element></my-element>`);
el.restore();

The html literal is from lit-html which provides for other usage patterns:

@import {fixture, html} from  "@domx/testutils";

const userDetailsEl= userId => html`<user-details user-id="${userId}"></user-details>`;
const el = fixture(userDetailsEl(123));
el.restore();

The fixture supports typing

const el= fixture<UserDetails>(html`<user-details></user-details>`);
console.log(el.userId);
el.restore();