chaijs / chai

BDD / TDD assertion framework for node.js and the browser that can be paired with any testing framework.
https://chaijs.github.io
MIT License
8.11k stars 694 forks source link

fix: support some virtual contexts in `toThrow` #1609

Closed 43081j closed 3 months ago

43081j commented 6 months ago

This adds support for VM situations where we pass a RegExp from another process.

Note that we don't have a full fix for this stuff until check-error also supports Error being from another origin.

There's also a tiny fix in here for supporting throw ''. I have left a PR comment by the relevant line of code

43081j commented 4 months ago

@koddsson could you re-review this? i updated slightly to support throwing of anything (so even throw undefined will work)

and i wrapped getConstructorName in a try/catch since it may be possible we pass a non-constructable function to it in super weird cases