Skip to content

Better output from to have properties #317

Open
@msiebuhr

Description

@msiebuhr
> var expect = require('unexpected');
> expect({a:1, b:2}, 'to have properties', ['a', 'b', 'c'])
UnexpectedError:
expected { a: 1, b: 2 } to have properties [ 'a', 'b', 'c' ]

This gets rather pointless when the tested object has more than a few dozen properties. And it doesn't tell you if it considers the required properties as strict set equality or a subset.

To get around this, I've re-purposed the code from #255 (comment) to this bastard-thing:

> expect(Object.keys({a:1, b:2}), 'to be a subset of', ['b', 'c']);
expected [ 'a', 'b' ] to be a subset of [ 'b', 'c' ]
[
  'a', // should be removed
  'b'
]

(Yes, I know the assertion isn't the same, but it illustrates the difference in output quite well.)

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