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 eaced80
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 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
36 changes: 19 additions & 17 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}) => {

Check failure on line 15 in test/core/test/sequential-sequence-concurrent.test.ts

View workflow job for this annotation

GitHub Actions / Lint: node-latest, ubuntu-latest

A space is required after '{'

Check failure on line 15 in test/core/test/sequential-sequence-concurrent.test.ts

View workflow job for this annotation

GitHub Actions / Lint: node-latest, ubuntu-latest

A space is required before '}'
await delay(50)
expect(task.concurrent).toBeFalsy()
expect(++count).toBe(1)
})

test('second test completes second', ({task}) => {

Check failure on line 21 in test/core/test/sequential-sequence-concurrent.test.ts

View workflow job for this annotation

GitHub Actions / Lint: node-latest, ubuntu-latest

A space is required after '{'

Check failure on line 21 in test/core/test/sequential-sequence-concurrent.test.ts

View workflow job for this annotation

GitHub Actions / Lint: node-latest, ubuntu-latest

A space is required before '}'
expect(task.concurrent).toBeFalsy()
expect(++count).toBe(2)
})
})

test.sequential('third test completes third', async ({task}) => {

Check failure on line 27 in test/core/test/sequential-sequence-concurrent.test.ts

View workflow job for this annotation

GitHub Actions / Lint: node-latest, ubuntu-latest

A space is required after '{'

Check failure on line 27 in test/core/test/sequential-sequence-concurrent.test.ts

View workflow job for this annotation

GitHub Actions / Lint: node-latest, ubuntu-latest

A space is required before '}'
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}) => {

Check failure on line 33 in test/core/test/sequential-sequence-concurrent.test.ts

View workflow job for this annotation

GitHub Actions / Lint: node-latest, ubuntu-latest

A space is required after '{'

Check failure on line 33 in test/core/test/sequential-sequence-concurrent.test.ts

View workflow job for this annotation

GitHub Actions / Lint: node-latest, ubuntu-latest

A space is required before '}'
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)
})
});

Check failure on line 37 in test/core/test/sequential-sequence-concurrent.test.ts

View workflow job for this annotation

GitHub Actions / Lint: node-latest, ubuntu-latest

Extra semicolon

0 comments on commit eaced80

Please sign in to comment.