Testcafe is an cross browser test framework that runs on Node.js. While setting up to use it for the first time I bumped into the following error, which maybe isn't as clear as could be, but is basically saying that you have several test contexts in your test run:
1) - Error in fixture.beforeEach hook -
ClientFunction cannot implicitly resolve the test run in context of which it should be
executed. If you need to call ClientFunction from the Node.js API callback, pass the test
controller manually via ClientFunction's `.with({ boundTestRun: t })` method first. Note
that you cannot execute ClientFunction outside the test code.
If you see this error, check you have not accidently bind mounted your local node_modules
into your container. Doing so could mean a different instance of the test controller because (from Nodejs docs https://nodejs.org/api/modules.html#module-caching-caveats):
Modules are cached based on their resolved filename. Since modules may resolve to a different
filename based on the location of the calling module (loading from node_modules folders), it
is not a guarantee that require('foo') will always return the exact same object, if it would
resolve to different files.
So if you accidently bind mount your local node_modules
into the container, node can end up resolving two different testcafe libraries in your project, resulting in different test controller instances within the same test.