0.1.0 • Published 6 years ago

chai-parse-as-json v0.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

chai-parse-as-json

parse-as-json is a simple assertion plugin for Chai that allows one to assert a string to be valid JSON and then chain assertions about the parsed value.

The purpose is to replace clumsy assertions such as:

expect(JSON.parse(response.payload)).to.deep.equal({msg: 'Hello'})

with more expressive:

expect(response).property('payload').to.parse.as.json.and.to.deep.equal({msg: 'Hello'})

Usage

Just chai.use the plugin and you're set:

chai.use(require('chai-parse-as-json'))
0.1.0

6 years ago