-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(runner): ensure sequential suite overrides sequence.concurrent (#…
…6653) Co-authored-by: Hiroshi Ogawa <hi.ogawa.zz@gmail.com>
- Loading branch information
Showing
6 changed files
with
152 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
test/config/fixtures/sequence-concurrent/sequence-concurrent-false-concurrent.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { describe, expect, test, vi } from 'vitest' | ||
|
||
const delay = (timeout: number) => new Promise(resolve => setTimeout(resolve, timeout)) | ||
|
||
let count = 0 | ||
|
||
describe.concurrent('concurrent suite', () => { | ||
test('first test completes last', async ({ task }) => { | ||
await delay(40) | ||
expect(task.concurrent).toBeTruthy() | ||
expect(++count).toBe(4) | ||
}) | ||
|
||
test('second test completes third', async ({ task }) => { | ||
await delay(30) | ||
expect(task.concurrent).toBeTruthy() | ||
expect(++count).toBe(3) | ||
}) | ||
}) | ||
|
||
test.concurrent('third test completes second', async ({ task }) => { | ||
await delay(20) | ||
expect(task.concurrent).toBeTruthy() | ||
expect(++count).toBe(2) | ||
}) | ||
|
||
test.concurrent('last test completes first', async ({ task }) => { | ||
await delay(10) | ||
expect(task.concurrent).toBeTruthy() | ||
expect(++count).toBe(1) | ||
}) |
31 changes: 31 additions & 0 deletions
31
test/config/fixtures/sequence-concurrent/sequence-concurrent-false-sequential.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { describe, expect, test, vi } from 'vitest' | ||
|
||
const delay = (timeout: number) => new Promise(resolve => setTimeout(resolve, timeout)) | ||
|
||
let count = 0 | ||
|
||
describe('sequential suite', () => { | ||
test('first test completes first', async ({ task }) => { | ||
await delay(40) | ||
expect(task.concurrent).toBeFalsy() | ||
expect(++count).toBe(1) | ||
}) | ||
|
||
test('second test completes second', async ({ task }) => { | ||
await delay(30) | ||
expect(task.concurrent).toBeFalsy() | ||
expect(++count).toBe(2) | ||
}) | ||
}) | ||
|
||
test('third test completes third', async ({ task }) => { | ||
await delay(20) | ||
expect(task.concurrent).toBeFalsy() | ||
expect(++count).toBe(3) | ||
}) | ||
|
||
test('last test completes last', async ({ task }) => { | ||
await delay(10) | ||
expect(task.concurrent).toBeFalsy() | ||
expect(++count).toBe(4) | ||
}) |
31 changes: 31 additions & 0 deletions
31
test/config/fixtures/sequence-concurrent/sequence-concurrent-true-concurrent.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { describe, expect, test, vi } from 'vitest' | ||
|
||
const delay = (timeout: number) => new Promise(resolve => setTimeout(resolve, timeout)) | ||
|
||
let count = 0 | ||
|
||
describe('concurrent suite', () => { | ||
test('first test completes last', async ({ task }) => { | ||
await delay(40) | ||
expect(task.concurrent).toBeTruthy() | ||
expect(++count).toBe(4) | ||
}) | ||
|
||
test('second test completes third', async ({ task }) => { | ||
await delay(30) | ||
expect(task.concurrent).toBeTruthy() | ||
expect(++count).toBe(3) | ||
}) | ||
}) | ||
|
||
test('third test completes second', async ({ task }) => { | ||
await delay(20) | ||
expect(task.concurrent).toBeTruthy() | ||
expect(++count).toBe(2) | ||
}) | ||
|
||
test('last test completes first', async ({ task }) => { | ||
await delay(10) | ||
expect(task.concurrent).toBeTruthy() | ||
expect(++count).toBe(1) | ||
}) |
18 changes: 7 additions & 11 deletions
18
...st/sequential-sequence-concurrent.test.ts → ...quence-concurrent-true-sequential.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,31 @@ | ||
import { describe, expect, test, vi } from 'vitest' | ||
|
||
vi.setConfig({ | ||
sequence: { | ||
concurrent: true, | ||
}, | ||
}) | ||
|
||
const delay = (timeout: number) => new Promise(resolve => setTimeout(resolve, timeout)) | ||
|
||
let count = 0 | ||
|
||
describe.sequential('running sequential suite when sequence.concurrent is true', () => { | ||
describe.sequential('sequential suite', () => { | ||
test('first test completes first', async ({ task }) => { | ||
await delay(50) | ||
await delay(40) | ||
expect(task.concurrent).toBeFalsy() | ||
expect(++count).toBe(1) | ||
}) | ||
|
||
test('second test completes second', ({ task }) => { | ||
test('second test completes second', async ({ task }) => { | ||
await delay(30) | ||
expect(task.concurrent).toBeFalsy() | ||
expect(++count).toBe(2) | ||
}) | ||
}) | ||
|
||
test.sequential('third test completes third', async ({ task }) => { | ||
await delay(50) | ||
await delay(20) | ||
expect(task.concurrent).toBeFalsy() | ||
expect(++count).toBe(3) | ||
}) | ||
|
||
test.sequential('fourth test completes fourth', ({ task }) => { | ||
test.sequential('last test completes last', async ({ task }) => { | ||
await delay(10) | ||
expect(task.concurrent).toBeFalsy() | ||
expect(++count).toBe(4) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { expect, test } from 'vitest' | ||
|
||
import { runVitest } from '../../test-utils' | ||
|
||
test('should run suites and tests concurrently unless sequential specified when sequence.concurrent is true', async () => { | ||
const { stderr, stdout } = await runVitest({ | ||
root: './fixtures/sequence-concurrent', | ||
include: ['sequence-concurrent-true-*.test.ts'], | ||
sequence: { | ||
concurrent: true, | ||
}, | ||
}) | ||
|
||
expect(stderr).toBe('') | ||
|
||
expect(stdout).toContain('✓ sequence-concurrent-true-sequential.test.ts > sequential suite > first test completes first') | ||
expect(stdout).toContain('✓ sequence-concurrent-true-sequential.test.ts > sequential suite > second test completes second') | ||
expect(stdout).toContain('✓ sequence-concurrent-true-sequential.test.ts > third test completes third') | ||
expect(stdout).toContain('✓ sequence-concurrent-true-sequential.test.ts > last test completes last') | ||
expect(stdout).toContain('✓ sequence-concurrent-true-concurrent.test.ts > concurrent suite > first test completes last') | ||
expect(stdout).toContain('✓ sequence-concurrent-true-concurrent.test.ts > concurrent suite > second test completes third') | ||
expect(stdout).toContain('✓ sequence-concurrent-true-concurrent.test.ts > third test completes second') | ||
expect(stdout).toContain('✓ sequence-concurrent-true-concurrent.test.ts > last test completes first') | ||
expect(stdout).toContain('Test Files 2 passed (2)') | ||
}) | ||
|
||
test('should run suites and tests sequentially unless concurrent specified when sequence.concurrent is false', async () => { | ||
const { stderr, stdout } = await runVitest({ | ||
root: './fixtures/sequence-concurrent', | ||
include: ['sequence-concurrent-false-*.test.ts'], | ||
sequence: { | ||
concurrent: false, | ||
}, | ||
}) | ||
|
||
expect(stderr).toBe('') | ||
|
||
expect(stdout).toContain('✓ sequence-concurrent-false-sequential.test.ts > sequential suite > first test completes first') | ||
expect(stdout).toContain('✓ sequence-concurrent-false-sequential.test.ts > sequential suite > second test completes second') | ||
expect(stdout).toContain('✓ sequence-concurrent-false-sequential.test.ts > third test completes third') | ||
expect(stdout).toContain('✓ sequence-concurrent-false-sequential.test.ts > last test completes last') | ||
expect(stdout).toContain('✓ sequence-concurrent-false-concurrent.test.ts > concurrent suite > first test completes last') | ||
expect(stdout).toContain('✓ sequence-concurrent-false-concurrent.test.ts > concurrent suite > second test completes third') | ||
expect(stdout).toContain('✓ sequence-concurrent-false-concurrent.test.ts > third test completes second') | ||
expect(stdout).toContain('✓ sequence-concurrent-false-concurrent.test.ts > last test completes first') | ||
expect(stdout).toContain('Test Files 2 passed (2)') | ||
}) |