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 quite often find myself in need to assert for nested properties where the path isn't always fully known. Most of the times when I want to check whether a nested array contains an object with a certain property. Would it be possible to allow wildcards in the path?
// maybe something likeassert.nestedPropertyVal(obj,'foo[?].bar','baz');// orassert.nestedPropertyVal(obj,'foo[*].bar','baz');// or maybe even with a regexassert.nestedPropertyVal(obj,'foo[/.*/].bar','baz');
The text was updated successfully, but these errors were encountered:
Instead of requiring some special parsing, just materialize the property path with an array, use strings for constants and regexes for dynamic parts. This does not support "any-depth" matches (such as git's wildstar **) but you could add a symbol for it or just write you own chai plugin using something based on minimatch for this kind of advanced feature.
Hey @Janpot thanks for the issue. Thanks for the extra comments @demurgos.
We'll look into adding this for Chai 5. We've added this to our Roadmap to investigate further. We'll be releasing chai 5 soon, but for now I'll close this issue because it is tracked on our roadmap.
I quite often find myself in need to assert for nested properties where the path isn't always fully known. Most of the times when I want to check whether a nested array contains an object with a certain property. Would it be possible to allow wildcards in the path?
The text was updated successfully, but these errors were encountered: