GithubHelp home page GithubHelp logo

isabella232 / jasmine-json Goto Github PK

View Code? Open in Web Editor NEW

This project forked from atom/jasmine-json

0.0 0.0 0.0 144 KB

Match objects in jasmine with legit error output

License: MIT License

CoffeeScript 100.00%

jasmine-json's Introduction

Jasmine JSON matcher

Comparing large objects with jasmine works great until you get an error, when it dumps the entire object to the console in a completely human unreadable format.

This package adds a toEqualJson matcher to jasmine that will generate nice diffs on error. It will tell you which keys differ, and why.

# In your spec helper
require 'jasmine-json'

# In your specs

describe "something", ->
  it "tests json", ->
    someObject =
      one: 1
      two:
        three: 5
        four: 4

    expect(someObject).toEqualJson
      one: 1
      two:
        three: 3
        four: 4
        five: 5

It will give you the path of the failure:

JSON is not equal:
two:
  actual:   has keys ["four","three"]
  expected: has keys ["five","four","three"]

If there are several errors, it will report all of them:

it "tests json", ->
    someObject =
      two:
        three:
          four:
            five: 4
            six: 5
            seven: 6

    expect(someObject).toEqualJson
      two:
        three:
          four:
            five: 5
            six: 6
            seven: 7

Reports:

JSON is not equal:
two.three.four.five:
  actual:   4
  expected: 5
two.three.four.six:
  actual:   5
  expected: 6
two.three.four.seven:
  actual:   6
  expected: 7

jasmine-json's People

Contributors

benogle avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.