preact-jsx-chai-match-template

0.2.3 • Public • Published

preact-jsx-chai-match-template

A method that adds assertions with html-looks-like to Chai for testing Preact components.

Installation

  1. Download the module

    npm install preact-jsx-chai-match-template --save-dev
    
  2. 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)

Readme

Keywords

none

Package Sidebar

Install

npm i preact-jsx-chai-match-template

Weekly Downloads

2

Version

0.2.3

License

MIT

Last publish

Collaborators

  • eduardoboucas