chai-structured-like
A Chai plugin with chainable helper assertions, comparing the structure of two objects
Last updated 2 years ago by xasdx .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install chai-structured-like 
SYNC missed versions from official npm registry.

chai-structured-like

Build Status Coverage Status npm version

A Chai plugin with chainable helper assertions, comparing the structure of two objects

What it does

Asserts that two objects has the same structure. The structure of objects are equal when:

  • The objects have the same number of properties
  • The properties match by name
  • The properties match by type

So { a: 0, b: true, c: "hi" } and { a: 0, b: false, c: "hello" } are considered structurally equal

How to install it

npm install chai-structured-like --save

How to use it

You can compare the structure of two objects:

expect({ n: 0, m: true, s: "hi" }).to.be.structuredLike({ n: 1, m: false, s: "hey" })

Or even compare the structure of nested objects:

expect({ a: 1, b: { c: "" }}).to.be.structuredLike({ a: 123, b: { c: "str" }})

Or use the shorter structured alias

expect({ a: 1, b: [] }).to.be.structured({ a: 0, b: [true] })

Current Tags

  • 1.1.0                                ...           latest (2 years ago)

3 Versions

  • 1.1.0                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (4)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |