# pretest

> Testing framework for Preact inspired by Enzyme.

Latest version **1.1.0** (published 2017-05-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install pretest
pnpm add pretest
yarn add pretest
bun add pretest
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2017-05-18 |
| First published | 2017-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | rkostrzewski |
| Maintainers | rkostrzewski |

## Links

- npm: https://www.npmjs.com/package/pretest
- npm.io page: https://npm.io/package/pretest

## Dependencies (2)

- [jsdom](https://npm.io/package/jsdom.md) ^10.0.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.4

## Recent versions

- 1.1.0 (latest) — 2017-05-18
- 1.0.0 — 2017-05-07
- 0.0.1 — 2017-04-23

## README

# Pretest

[![Travis](https://img.shields.io/travis/rkostrzewski/pretest.svg)](https://travis-ci.org/rkostrzewski/pretest)[![Codecov](https://img.shields.io/codecov/c/github/rkostrzewski/pretest.svg)](https://codecov.io/gh/rkostrzewski/pretest)[![npm](https://img.shields.io/npm/v/pretest.svg)]()[![Greenkeeper badge](https://badges.greenkeeper.io/rkostrzewski/pretest.svg)](https://greenkeeper.io/)

Pretest is a testing framework for Preact inspired by [Enzyme](https://github.com/airbnb/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](https://github.com/rkostrzewski/pretest/tree/master/CONTRIBUTING.md) 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](https://github.com/tmpvar/jsdom).

# Usage

Visit [API](https://github.com/rkostrzewski/pretest/tree/master/docs/API) and [Examples](https://github.com/rkostrzewski/pretest/tree/master/docs/EXAMPLES.md) 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

- [Glossary](https://github.com/rkostrzewski/pretest/tree/master/docs/GLOSSARY.md) - explains differences between different renderers
- [API](https://github.com/rkostrzewski/pretest/tree/master/docs/API)
- [Examples](https://github.com/rkostrzewski/pretest/tree/master/docs/EXAMPLES.md)

# Future work

What's planned:
- Sending events to components (click, input, etc)
- Contributing description

---
_Source: https://npm.io/package/pretest · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
