Skip to content

eduardoboucas/preact-jsx-chai-match-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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)

About

πŸ—œ A method that adds assertions with html-looks-like to Chai for testing Preact components

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published