1.1.0 • Published 7 years ago

pretest v1.1.0

Weekly downloads
229
License
MIT
Repository
-
Last release
7 years ago

Pretest

TravisCodecovnpmGreenkeeper badge

Pretest is a testing framework for Preact inspired by Enzyme.

It features similar intuitive API, lazy evaluation for better performance, and testing with and without DOM.

Pretest is testing framework agnostic - meaning you can use it with any testing framework, be it Jasmine, Mocha, Jest, AVA or anything else.

Pretest's core logic is also platform agnostic - meaning it can be used with different Virtual Dom platform like Inferno, virtual-dom and others (provided platform definitions exists). See Contributing guidelines if you'd like to implement new platform.

Supported platforms

  • Preact 8

Installation

Installing Pretest is straightforward. Using npm:

npm install pretest -d

or yarn:

yarn add pretest -D

If you wish to use mounted renderers (mount and bashallowMount) DOM implementation must be available to pretest. That means running tests either in browser or using DOM implementation like jsdom.

Usage

Visit API and Examples for further reading.

Basic example:

import { h } from 'preact'
import { by, shallowMount, json } from 'pretest'
import App from './App'
import HomePage from './HomePage'

describe('App', () => {
  it('should render Home page.', () => {
    const wrapper = shallowMount(<App />)

    expect(wrapper.contains(by.jsx(<HomePage loaded />))).toEqual(true)
  })

  it('should render three links.', () => {
    const wrapper = json(<App />)

    const links = wrapper.find(by.name('a'))

    expect(links.length()).toEqual(3)
  })
})

Documentation

Future work

What's planned:

  • Sending events to components (click, input, etc)
  • Contributing description