# chai-interface

> chai assertions about an object's interface

Latest version **2.0.3** (published 2016-02-18) · MIT license · 0 weekly downloads

## Install

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

## 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 | 2.0.3 |
| Published | 2016-02-18 |
| First published | 2013-01-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Agile Diagnosis |
| Maintainers | jden |
| Keywords | chai, chai-plugin, browser, objects, test, interface, plugin |

## Links

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

## Dependencies (1)

- [tracery](https://npm.io/package/tracery.md) ^1.0.3

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 2.0.3 (latest) — 2016-02-18
- 2.0.2 — 2015-05-21
- 2.0.1 — 2015-05-21
- 2.0.0 — 2015-05-20
- 1.2.0 — 2015-04-14
- 1.1.0 — 2013-02-10
- 1.0.1 — 2013-02-07
- 1.0.0 — 2013-01-30

## README

# chai-interface
chai assertions about an object's interface

## installation

    $ npm install chai-interface

## usage
```js
    var chai = require('chai')
    chai.should()
    chai.use(require('chai-interface'))

    var foo = {
      bar: true,
      baz: 'green',
      qux: 37,
      quack: function () {},
      ducks: [1, 2, 3]
    }

    foo.should.have.interface({
      bar: Boolean,
      baz: String,
      qux: Number,
      quack: Function,
      ducks: Array
    })
```

Also, more complex, nested objects!
```js
    var user = {
      name: {
        first: 'Betty',
        last: 'Dodson'
      },
      emails: {
        work: 'b.dodson@megacorp.com',
        home: 'butterflychica947@lol.com',
        school: 'bdodso4@stateu.edu'
      }
    }

    user.should.have.interface({
      name: {
        first: String,
        last: String
      },
      emails: {
        work: String,
        home: String,
        school: String
      }
    })
```

## example error message

    Interface not as expected:
    {
      "bars": {
        "actual": "Array<String>",
        "expected": "Array<Number>",
        "actualValue": [
          "a",
          "b",
          "c"
        ]
      }
    }

## by the power of [tracery](https://github.com/AgileDiagnosis/tracery)

`chai-interface` does interface checking using `tracery`

## contributors

jden <jason@denizac.org> @leJDen

Please submit pull requests and issues through github.

## license

MIT
(c) 2013 Agile Diagnosis, Inc.
see LICENSE.md

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