-
-
Notifications
You must be signed in to change notification settings - Fork 204
Description
🚀 Feature Request
Make it possible to generate objects from other realms.
Motivation
Sometimes objects can come from other realms (e.g. iframes, web workers, Node vm contexts, etc.)
instanceof checks don't work the way you expect on those, but some libraries want to ensure they still work properly regardless of whether an object is from the current realm or another one. It would be useful to be able automatically generate objects from another realm to test.
Example
I think this could probably be provided as a higher-order arbitrary, similarly to fc.option. Something like:
// generate cross-realm versions of `arb` half the time
fc.crossRealm(arb, { freq: 2 })The generation of the arb's value would be run in another realm at the given frequency.
Since fast-check supports both Node and the browser (I think), you might end up needing to take two different approaches for creating a cross-realm object depending on the environment.