@@ -1036,7 +1036,9 @@ function testCaseHook (TestCaseRunner, version) {
10361036// Valid for old and new cucumber versions
10371037function getCucumberOptions ( adapterOrCoordinator ) {
10381038 if ( adapterOrCoordinator . adapter ) {
1039- return adapterOrCoordinator . adapter . worker ?. options || adapterOrCoordinator . adapter . options
1039+ return adapterOrCoordinator . adapter . worker ?. options ||
1040+ adapterOrCoordinator . adapter . executor ?. options ||
1041+ adapterOrCoordinator . adapter . options
10401042 }
10411043 return adapterOrCoordinator . options
10421044}
@@ -1434,13 +1436,14 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
14341436 }
14351437}
14361438
1437- function patchCucumberWorkerRunTestCase ( workerPackage , isWorker ) {
1438- const workerPrototype = workerPackage ?. Worker ?. prototype
1439- if ( ! workerPrototype || patchedCucumberWorkers . has ( workerPrototype ) ) return
1439+ function patchCucumberWorkerRunTestCase ( runtimeExecutorPackage , isWorker ) {
1440+ const runtimeExecutorPrototype =
1441+ runtimeExecutorPackage ?. Worker ?. prototype || runtimeExecutorPackage ?. Executor ?. prototype
1442+ if ( ! runtimeExecutorPrototype || patchedCucumberWorkers . has ( runtimeExecutorPrototype ) ) return
14401443
1441- patchedCucumberWorkers . add ( workerPrototype )
1444+ patchedCucumberWorkers . add ( runtimeExecutorPrototype )
14421445 shimmer . wrap (
1443- workerPrototype ,
1446+ runtimeExecutorPrototype ,
14441447 'runTestCase' ,
14451448 runTestCase => getWrappedRunTestCase ( runTestCase , true , isWorker )
14461449 )
@@ -1572,15 +1575,25 @@ addHook({
15721575// `getWrappedRunTestCase` does two things:
15731576// - generates suite start and finish events in the main process,
15741577// - handles EFD in both the main process and the worker process.
1578+ // Shimmer is required because this wrapper may invoke the original test case multiple times and mutate runtime options.
15751579addHook ( {
15761580 name : '@cucumber/cucumber' ,
1577- versions : [ '>=11.0.0' ] ,
1581+ versions : [ '>=11.0.0 <13.2.0 ' ] ,
15781582 file : 'lib/runtime/worker.js' ,
15791583} , ( workerPackage ) => {
15801584 patchCucumberWorkerRunTestCase ( workerPackage , ! ! getEnvironmentVariable ( 'CUCUMBER_WORKER_ID' ) )
15811585 return workerPackage
15821586} )
15831587
1588+ addHook ( {
1589+ name : '@cucumber/cucumber' ,
1590+ versions : [ '>=13.2.0' ] ,
1591+ file : 'lib/runtime/executor.js' ,
1592+ } , ( executorPackage ) => {
1593+ patchCucumberWorkerRunTestCase ( executorPackage , ! ! getEnvironmentVariable ( 'CUCUMBER_WORKER_ID' ) )
1594+ return executorPackage
1595+ } )
1596+
15841597// `getWrappedStart` generates session start and finish events
15851598addHook ( {
15861599 name : '@cucumber/cucumber' ,
0 commit comments