Skip to content

Proposal: Add match.json(object) #191

@mantoni

Description

@mantoni

In referee, we have assert.json(actual, expected) which attempts to parse actual with JSON.parse and compares the result to expected. It would be nice to have a matcher that does the same and can be used like this:

assert.equals(actual, {
  some: 'thing',
  json: match.json({
    parsed: true
  })
});

Or with sinon assertions:

sinon.assert.calledWith(fake, match.json({
  my: 'json'
}));

I'm unsure about a naming ambiguity though: We also have assert.matchJson(actual, expectation) which parses actual with JSON.parse and compares the result to expected using the same semantics of assert.match.

How would match.json behave? And what would be the counterpart?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions