preact-jsx-chai-match-template
v0.2.3
Published
A method that adds assertions with html-looks-like to Chai for testing Preact components
Downloads
6
Readme
preact-jsx-chai-match-template
A method that adds assertions with html-looks-like to Chai for testing Preact components.
Installation
Download the module
npm install preact-jsx-chai-match-template --save-dev
Add it to Chai
import chai from 'chai' import assertMatch from 'preact-jsx-chai-match-template' chai.use(assertMatch)
Usage
const component = (
<div class="container">
<button type="button">Previous</button>
<div class="article">
<h1>Hello world</h1>
<p>This is a test</p>
</div>
<button type="button">Next</button>
</div>
)
const template = (
<div class="container">
(...)
<div class="article">
<h1>Hello world</h1>
(...)
</div>
(...)
</div>
)
expect(component).to.matchTemplate(template)