Skip to content
Draft
2 changes: 0 additions & 2 deletions compatibility/cck_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const CCK_IMPLEMENTATIONS_PATH = 'compatibility/features'
const UNSUPPORTED = [
// we aren't fully compliant yet for global hooks
'global-hooks-attachments',
'global-hooks-beforeall-error',
'global-hooks-afterall-error',
// not a test sample
'test-run-exception',
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { When, BeforeAll, AfterAll } from '../../../src'

BeforeAll({}, function () {
// no-op
})

BeforeAll({}, function () {
// no-op
})

When('a step passes', function () {
// no-op
})

AfterAll({}, function () {
// no-op
})

AfterAll({}, function () {
throw new Error('AfterAll hook went wrong')
})

AfterAll({}, function () {
// no-op
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { When, BeforeAll, AfterAll } from '../../../src'

BeforeAll({}, function () {
// no-op
})

BeforeAll({}, function () {
throw new Error('BeforeAll hook went wrong')
})

BeforeAll({}, function () {
// no-op
})

When('a step passes', function () {
// no-op
})

AfterAll({}, function () {
// no-op
})

AfterAll({}, function () {
// no-op
})
1 change: 1 addition & 0 deletions features/before_after_all_hooks_context.feature
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Feature: Before/After All Hooks Context
When I run cucumber-js
Then it passes

@parallel
Scenario: Works the same way on the parallel runtime
Given a file named "features/support/hooks.js" with:
"""
Expand Down
2 changes: 1 addition & 1 deletion features/dryrun_mode.feature
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Feature: Dryrun mode
When I run cucumber-js with `--dry-run`
Then it passes

@spawn
@parallel @spawn
Scenario: hooks should not execute in dry run, parallel runtime
Given a file named "features/step_definitions/cucumber_steps.js" with:
"""
Expand Down
1 change: 1 addition & 0 deletions features/esm.feature
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Feature: ES modules support
Then it runs 2 scenarios
And it passes

@parallel
Scenario: native modules work with parallel runtime
Given a file named "features/a.feature" with:
"""
Expand Down
1 change: 1 addition & 0 deletions features/loaders.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Feature: ESM loaders support
When I run cucumber-js with `--loader ts-node/esm --import features/steps.ts`
Then it passes

@parallel
Scenario: parallel runtime
When I run cucumber-js with `--loader ts-node/esm --import features/steps.ts --parallel 1`
Then it passes
Expand Down
1 change: 1 addition & 0 deletions features/parallel.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@parallel
Feature: Running scenarios in parallel

Scenario: running in parallel can improve speed if there are async operations
Expand Down
1 change: 1 addition & 0 deletions features/parallel_custom_assign.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@parallel
Feature: Running scenarios in parallel with custom assignment

@spawn
Expand Down
1 change: 1 addition & 0 deletions features/retry.feature
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ Feature: Retry flaky tests
And scenario "Flaky" attempt 1 step "Given a flaky step" has status "passed"
And it passes

@parallel
Scenario: retrying a flaky test will eventually make it pass (parallel)
Given a file named "features/a.feature" with:
"""
Expand Down
1 change: 1 addition & 0 deletions features/step_definition_snippets_custom_syntax.feature
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Feature: step definition snippets custom syntax
| async-await | -> | 'pending' |
| synchronous | -> | 'pending' |

@parallel
Scenario: Custom snippet syntax works in parallel runtime
When I run cucumber-js with `--parallel 2 --format-options '{"snippetInterface": "async-await", "snippetSyntax": "./coffeescript_syntax.js"}'`
Then it fails
Expand Down
33 changes: 25 additions & 8 deletions src/runtime/coordinator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,32 @@ export class Coordinator implements Runtime {
},
} satisfies Envelope)

const assembledTestCases = await assembleTestCases(
this.testRunStartedId,
this.eventBroadcaster,
this.newId,
this.sourcedPickles,
this.supportCodeLibrary
)
await this.adapter.setup()

const success = await this.adapter.run(assembledTestCases)
const successByPhase = {
beforeAllHooks: false,
testCases: false,
afterAllHooks: false,
}
successByPhase.beforeAllHooks = await this.adapter.runBeforeAllHooks()
if (successByPhase.beforeAllHooks) {
const assembledTestCases = await assembleTestCases(
this.testRunStartedId,
this.eventBroadcaster,
this.newId,
this.sourcedPickles,
this.supportCodeLibrary
)
successByPhase.testCases =
await this.adapter.runTestCases(assembledTestCases)
}
successByPhase.afterAllHooks = await this.adapter.runAfterAllHooks()
const success =
successByPhase.beforeAllHooks &&
successByPhase.testCases &&
successByPhase.afterAllHooks

await this.adapter.teardown()

this.eventBroadcaster.emit('envelope', {
testRunFinished: {
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/make_runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { SupportCodeLibrary } from '../support_code_library_builder/types'
import FormatterBuilder from '../formatter/builder'
import { FormatOptions } from '../formatter'
import { Runtime } from './types'
import { ChildProcessAdapter } from './parallel/adapter'
import { InProcessAdapter } from './serial/adapter'
import { Coordinator } from './coordinator'
import { WorkerThreadsAdapter } from './parallel/adapter'

export async function makeRuntime({
environment,
Expand Down Expand Up @@ -62,7 +62,7 @@ async function makeAdapter(
newId: () => string
) {
if (options.parallel > 0) {
return new ChildProcessAdapter(
return new WorkerThreadsAdapter(
testRunStartedId,
environment,
logger,
Expand Down
44 changes: 0 additions & 44 deletions src/runtime/parallel/README.md

This file was deleted.

Loading
Loading