-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Description
🐛 Bug Report
When toMatchSnapshot(propertyMatchers, snapshotName) has null as the first argument, Jest prints a confusing error:
Received value does not match snapshot properties for "foo: hello 1".
Expected snapshot to match properties:
null
Received:
"foo"
To Reproduce
Steps to reproduce the behavior:
it('foo', () =>
expect('foo').toMatchSnapshot(null, 'hello')
);with Jest 23
Expected behavior
I only wanted to specify snapshotName. The docs say it's the second argument: http://jestjs.io/docs/en/expect.html#tomatchsnapshotpropertymatchers-snapshotname
I have no idea what "property matchers" are and am not currently interested in them. (The docs fail to mention their format.) I passed null because I don't know what their default value is (the docs fail to mention that too).
I couldn't figure out for quite some time why my tests were failing. I expected null to be treated as a "missing" value for propertyMatchers instead of trying to treat it as some kind of a shape.
Link to repl or repo (highly encouraged)
Repl seems to be on an older Jest version without this problem.
But the above repro works for a clear Jest 23 install.