Skip to content

Commit

Permalink
fix(runner): ensure sequential suite overrides sequence.concurrent
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyddall committed Oct 6, 2024
1 parent 9ece395 commit 6c45eaa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
9 changes: 5 additions & 4 deletions packages/runner/src/suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,16 +520,17 @@ function createSuite() {
optionsOrFactory,
)

const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false
const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false

// inherit options from current suite
if (currentSuite?.options) {
options = { ...currentSuite.options, ...options }
}

// inherit concurrent / sequential from suite
const isConcurrent
= options.concurrent || (this.concurrent && !this.sequential)
const isSequential
= options.sequential || (this.sequential && !this.concurrent)
const isConcurrent = isConcurrentSpecified || (options.concurrent && !isSequentialSpecified)
const isSequential = isSequentialSpecified || (options.sequential && !isConcurrentSpecified)
options.concurrent = isConcurrent && !isSequential
options.sequential = isSequential && !isConcurrent

Expand Down
34 changes: 18 additions & 16 deletions test/core/test/sequential-sequence-concurrent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,28 @@ const delay = (timeout: number) => new Promise(resolve => setTimeout(resolve, ti

let count = 0

describe.sequential('running sequential suite when sequence.concurrent is true', () => {
test('first test completes first', async ({ task }) => {
describe.concurrent('concurrent parent suite', () => {
describe.sequential('running sequential suite when sequence.concurrent is true', () => {
test('first test completes first', async ({ task }) => {
await delay(50)
expect(task.concurrent).toBeFalsy()
expect(++count).toBe(1)
})

test('second test completes second', ({ task }) => {
expect(task.concurrent).toBeFalsy()
expect(++count).toBe(2)
})
})

test.sequential('third test completes third', async ({ task }) => {
await delay(50)
expect(task.concurrent).toBeFalsy()
expect(++count).toBe(1)
expect(++count).toBe(3)
})

test('second test completes second', ({ task }) => {
test.sequential('fourth test completes fourth', ({ task }) => {
expect(task.concurrent).toBeFalsy()
expect(++count).toBe(2)
expect(++count).toBe(4)
})
})

test.sequential('third test completes third', async ({ task }) => {
await delay(50)
expect(task.concurrent).toBeFalsy()
expect(++count).toBe(3)
})

test.sequential('fourth test completes fourth', ({ task }) => {
expect(task.concurrent).toBeFalsy()
expect(++count).toBe(4)
})

0 comments on commit 6c45eaa

Please sign in to comment.