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
Our product (Wallaby) uses mocha programmatically and by default reuses the node process between test runs. In the latest version of mocha (v9) subsequent changes to a test file are not executing after the first test run. It appears that the import only happens on the first test run which means that on subsequent calls, the context functions (it, describe, etc.) are not re-executed and test execution bails.
We are not sure if this problem is specific to how Wallaby is calling mocha but we would not have thought so. In the past, we have had to add a cache breaker in the past for other parts of Wallaby and Quokka that natively support ESM. Specifically, this line of code is causing the problem:
For now, we have patched this ourselves by adding a cache breaker as we have in other parts of Wallaby (same technique as described in this blog post). So the code becomes:
After following our suggested technique, we had a problem with the change we suggested. The query string needs to be added after the pathToFileUrl. Have updated the original issue description so that it is now correct.
Mocha is supporting Node's native ESM support since v7.1.0. The ESM loader uses its one cache, different to require.cache of CJS files. Node doesn't offer any API to clear the ESM cache, and afaik they will probably never do.
For that same reason we don't support watch mode with ESM test files, yet. We have no solution to clear the cache either, and we probably will have to spawn a new process for each watch re-run.
In the latest version of mocha (v9) [...]
There shouldn't be any changes refering to ESM cache from v8.4.0 to v9.0.0. Is there any different behavior?
Hey guys - congrats on releasing v9! 🎉
Our product (Wallaby) uses mocha programmatically and by default reuses the node process between test runs. In the latest version of mocha (
v9
) subsequent changes to a test file are not executing after the first test run. It appears that the import only happens on the first test run which means that on subsequent calls, the context functions (it
,describe
, etc.) are not re-executed and test execution bails.We are not sure if this problem is specific to how Wallaby is calling mocha but we would not have thought so. In the past, we have had to add a cache breaker in the past for other parts of Wallaby and Quokka that natively support ESM. Specifically, this line of code is causing the problem:
For now, we have patched this ourselves by adding a cache breaker as we have in other parts of Wallaby (same technique as described in this blog post). So the code becomes:
The text was updated successfully, but these errors were encountered: