api: allow reuse of support code library between runs in the same process #1894
Labels
✅ accepted
The core team has agreed that it is a good idea to fix this
⚡ enhancement
Request for new functionality
Milestone
Describe the bug
When loading support code files, Cucumber 8 uses
import(...)
instead ofrequire('..')
. This is great, but without a way to reuse support library code, specified in #1711, it would break StrykerJS integration.NOTE: you might already know this to be the case, but I personally would love this to be fixed before the v8 release via this API: #1711 (comment). Otherwise, StrykerJS will be unable to support cucumber v8
To Reproduce
This code example works for
@cucumber/cucumber@7.3.2
, but not for@cucumber/cucumber@8.0.0-rc2
.In this example, the
DirectoryRequireCache
class is used, which is a utility that clears all local files from therequire.cache
.Expected behavior
Actual behavior:
Proposed solution
Implement the proposal mentioned here: #1711 (comment) before the v8 release.
Additional context
When you use
import(...)
to load a cjs module, nodejs will use the CommonJS loader initially to load that file. However, it places it in the "import cache" (for lack of a better word), which is the cache that we cannot clear. Any subsequentimport
s of that file will be reclaimed from that cache. This means that support code cannot be reloaded after it is loaded initially.I didn't realize this myself, until jasmine v4 got released last week, which broke the StrykerJS integration.
See for a code example demonstrating the issue stryker-mutator/stryker-js#2922 (comment)
The text was updated successfully, but these errors were encountered: