-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Per se, unexpected is great for (amongst other things) comparing more complex structures - including the calls to a mock.
There is a glitch, however: The following line fails w/ a somewhat strange error message:
expect(resp.status.mock.calls, 'to equal', [[500]]); // one call, w/ 500 as one and only argmsg is:
UnexpectedError:
expected [ [ 500 ] ] to equal [ [ 500 ] ]
Mismatching constructors Array should be Array
What does work is this:
const normalizeArray=(obj) => (Array.isArray(obj) ? [].concat(obj).map(c => normalizeArray(c)): obj); // hopefully an utils.js ;-)
expect(normalizeArray(resp.status.mock.calls), 'to equal', [[500]]);I didn't yet figure out what the root cause is. And there's a workaround, so it's not really critical.
Just wanted to let you know about the workaround (and I'm sure grateful if s/o can point me to an existing solution).
Metadata
Metadata
Assignees
Labels
No labels