0.2.3 • Published 7 years ago

preact-jsx-chai-match-template v0.2.3

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

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)
0.2.3

7 years ago

0.2.2

7 years ago