Skip to content

momocode/chai-parse-as-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'))

About

A simple Chai plugin to assert string to be valid JSON

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published