You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't find anything regarding a deep or nested match functionality. What I'm looking for is an assertion function which matches two objects based on regular expressions.
var result = {a: "contains foo", b: "contains bar"}
var expected = {a: /foo/, b: /bar/}
assert.deepMatch(result, expected)
This would be a combination of a deepEqual() and the match() assertion functions. This could be useful, in situations where an object contains unpredictable data following a pattern. In my case this is an id set by the database.
Do I miss something? I can't figure out a way to achieve this behavior without a workaround.
Thanks in advance
The text was updated successfully, but these errors were encountered:
Hi @numbnut, I'm currently not sure if this is common enough for us to cover it.
But well, we can discuss about this. It would be great to hear other people's opinions before giving a definitive answer to it.
For now you can use match individually to test each one of the object's properties, after all you are already kind of doing this when you create your expected object, so (in my opinion) there's not a big difference between creating an object with multiple RegExps and using multiple assertions with the same RegExps you put on your object.
Thanks for your feedback and please feel free to share further thoughts on this and ask any questions you would like to.
As @lucasfcosta says - I'm not sure if this is a common enough scenario for us to look at.
We have had similar issue before though, for example #426. We've also discussed the idea of having an api for making assertions on deep properties, for example #97 and #324. I've raised a new issue; #644 which I think we should focus on, and it would help you with the issues you're having.
I'll close this in favour of #644 for now, but let me know what you think - either in #644 or below 😄
I can't find anything regarding a deep or nested match functionality. What I'm looking for is an assertion function which matches two objects based on regular expressions.
This would be a combination of a deepEqual() and the match() assertion functions. This could be useful, in situations where an object contains unpredictable data following a pattern. In my case this is an id set by the database.
Do I miss something? I can't figure out a way to achieve this behavior without a workaround.
Thanks in advance
The text was updated successfully, but these errors were encountered: