🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pretest

Testing framework for Preact inspired by Enzyme.

1.1.0
latest
77

Supply Chain Security

100

Vulnerability

91

Quality

76

Maintenance

100

License

Version published
Maintainers
1
Created

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

FAQs

Package last updated on 18 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts