Consolidation of serial and parallel runtimes #2357
Replies: 2 comments 4 replies
-
Hi @davidjgoss thanks for mentioning me.
This is very useful for the StrykerJS use case, and I consider it a feature. It enables hot reload, making the
This is not the case for Mocha. The CLI might do it, but using the programmatic API and disable parallel mode, it executes in-process. I propose using the same solution as Mocha. It has an abstraction for running in-process (so, "serial" as you call it) and uses that code from the workers. If you go this route, making parallel with 1 worker the default from the CLI (when parallel is disabled / set to 1) would be fine for me. The result for the end-user would be the same.
This can be solved by good documentation and error messages. I'm in the camp of people who say NodeJS devs should know what a "loader" is and why it is needed/how to configure it (or choose to run cucumber on transpiled output). |
Beta Was this translation helpful? Give feedback.
-
Hey @davidjgoss - this sounds like a good idea! For context, here's how Serenity/JS integrates with Cucumber.js:
To support parallel execution using the model you're describing, Serenity/JS would need to be able to:
If we addressed the three above points, the "serial" mode could be Thinking aloud, if Cucumber allowed for the |
Beta Was this translation helpful? Give feedback.
-
Problem
cucumber-js has two runtime implementations internally:
parallel
option is on, tests are run on worker processes and they report their results back up to the coordinator processThis has a disadvantage in terms of complexity of the codebase, naturally - it's more code to maintain. But it's not too bad in the scheme of things.
It's a source of unexpected behaviour and bugs for users as things behave somewhat differently when using the parallel runtime e.g. global hooks.
The serial mode specifically presents problems for API use cases (with
runCucumber
). Because the user code is loaded in the same process and cached, subsequent runs in the same process don't load it again, resulting in . We introducedloadSupport
to work around this, but it's still confusing and doesn't cover all use cases. For example, if/when we want to add support for automatically rerunning tests when the files change, we can't really do that right now.Proposal
In cases where we currently use the serial runtime, instead just use the parallel runtime but with a single worker.
This would put us in step with other JavaScript test runners like Mocha and Jest, which also do all test execution on workers.
It would make it easier to work with ESM loaders, as we could pass a
--loader
option to the worker processes without affecting the main process or requiring the user to set it externally (as they have to now).Currently the parallel runtime loads user code once on the coordinator, and then again on each worker. The coordinator ones are used to generate the canonical step definition messages and the ids are kind of "synced" down to the workers, but it would be just as easy to have one worker designated the "leader" so it can do that part. This would solve the "cached user code" issue described above.
This could be phased in by at some point making
--parallel 1
the default behaviour, and allowing an override to use serial mode for a time.Considerations
This would have an impact on tools in the near ecosystem and we'd need to ensure we have these use cases covered off before doing this change. We really don't want to break things for people.
This would be a breaking change for the API, as we'd no longer support passing in a pre-loaded support code library to
runCucumber
, or returning in the response.loadSupport
would have no reason to exist. cc @nicojsTools like WDIO and Serenity are currently pretty much blocked on using the parallel runtime, see:
I think we'll need to first come up with a solution that allows integrators to pass data between coordinator and workers to solve these issues, and unlock this change. cc @tamil777selvan @jan-molak
Note this is currently a proposal and not being actively worked on - I'm looking for feedback and potential gotchas before doing anything meaningful about it.
Beta Was this translation helpful? Give feedback.
All reactions