# snabbdom-chai

> Flexible chai matchers for snabbdom

Latest version **1.0.2** (published 2016-09-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install snabbdom-chai
pnpm add snabbdom-chai
yarn add snabbdom-chai
bun add snabbdom-chai
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2016-09-07 |
| First published | 2016-09-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 14 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | James Lawson |
| Maintainers | jameslawson |
| Keywords | snabbdom, chai |

## Links

- npm: https://www.npmjs.com/package/snabbdom-chai
- Repository: https://github.com/jameslawson/snabbdom-chai
- Homepage: https://github.com/jameslawson/snabbdom-chai#readme
- Issues: https://github.com/jameslawson/snabbdom-chai/issues
- npm.io page: https://npm.io/package/snabbdom-chai

## Dependencies (14)

- [lodash.get](https://npm.io/package/lodash.get.md) ^4.4.2
- [lodash.map](https://npm.io/package/lodash.map.md) ^4.6.0
- [lodash.keys](https://npm.io/package/lodash.keys.md) ^4.2.0
- [lodash.some](https://npm.io/package/lodash.some.md) ^4.6.0
- [lodash.every](https://npm.io/package/lodash.every.md) ^4.6.0
- [lodash.first](https://npm.io/package/lodash.first.md) ^3.0.0
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.0
- [lodash.filter](https://npm.io/package/lodash.filter.md) ^4.6.0
- [lodash.forown](https://npm.io/package/lodash.forown.md) ^4.4.0
- [lodash.reduce](https://npm.io/package/lodash.reduce.md) ^4.6.0
- [lodash.foreach](https://npm.io/package/lodash.foreach.md) ^4.5.0
- [lodash.includes](https://npm.io/package/lodash.includes.md) ^4.3.0
- [lodash.isstring](https://npm.io/package/lodash.isstring.md) ^4.0.1
- [lodash.isundefined](https://npm.io/package/lodash.isundefined.md) ^3.0.1

## Recent versions

- 1.0.2 (latest) — 2016-09-07
- 1.0.1 — 2016-09-05
- 1.0.0 — 2016-09-05

## README

# snabbdom-chai

*Flexible chai matchers for snabbdom*

A [chai](http://chaijs.com/) plugin for [snabbdom](https://github.com/paldepind/snabbdom).

## Usage

Basics:
```javascript
expect(tree).to.have.tag('div');
expect(tree).to.have.text('hello');
expect(tree).to.have.class('foo');
expect(tree).to.have.classes(['foo', 'bar', 'baz']);
expect(tree).to.have.styles({ left: '10px', top: '0px', width: '20px' });
expect(tree).to.have.children(3);
expect(tree).to.have.attribute('src', 'http://first-image.png');
```

Subtree expectations:
```javascript
expect(tree).to.have.a.subtree.with.tag('div').inside;
expect(tree).to.have.a.subtree.with.text('hello').inside;
expect(tree).to.have.a.subtree.with.class('foo').inside;
expect(tree).to.have.a.subtree.with.classes(['foo', 'bar', 'baz']).inside
expect(tree).to.have.a.subtree.with.styles({ left: '10px', top: '0px', width: '20px' }).inside;
```

> **Important!** To use subtree expectations you must end your chai matchers with '`inside`'. 
If you fail to do this, *no assertion will be made* by chai, and the expectation 
will *always pass* (the value of `tree` will be ignored).

Chaining:
```javascript
expect(tree).to.have.tag('div').and.text('world');
expect(tree).to.have.class('foo').and.text('world').and.style({ display: 'none' });
expect(tree).to.have.a.subtree.with.tag('div').with.class('foo').inside;
expect(tree).to.have.a.subtree.with.tag('h1').class('bar').style({ color: 'red' }).and.text('world').inside;
```

Locating:
```javascript
expect(tree).at.root('some-class').to.have.tag('div');
expect(tree).at.root('some-class').to.have.a.subtree.with.tag('h1').inside;
```

Delegating to core chai:
```javascript
expect(tree).to.have.children.below(3);
expect(tree).to.have.classes.that.include.members(['hide', 'clearfix']);
expect(tree).to.have.text.that.has.length.within(2,4);
expect(tree).to.have.styles.that.have.all.keys('left', 'display', 'background');
```


## Installation

```
npm install snabbdom-chai --save-dev
```

```javascript
var chai = require('chai');
chai.use(require('snabbdom-chai'));
```

## License

MIT License.    
Copyright © 2016 James Lawson

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