-
-
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.
- Loading branch information
Showing
3 changed files
with
42 additions
and
35 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
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,42 @@ | ||
import { createDefer } from '@vitest/utils' | ||
import { describe, test, vi } from 'vitest' | ||
|
||
vi.setConfig({ maxConcurrency: 2 }) | ||
|
||
describe('limit for each suite', () => { | ||
// this test requires running 3 tests in parallel. | ||
// but, currently p-limit is applied for each suite layer, | ||
// so tests succeed. | ||
// | ||
// [0] [1] [2] | ||
// * -> | ||
// * -> | ||
// <- * | ||
// <------ | ||
|
||
const defers = [ | ||
createDefer<void>(), | ||
createDefer<void>(), | ||
createDefer<void>(), | ||
] | ||
|
||
describe('1st suite', { concurrent: true, concurrentSuite: true }, () => { | ||
test('a', async () => { | ||
defers[0].resolve() | ||
await defers[2] | ||
}) | ||
|
||
test('b', async () => { | ||
await defers[0] | ||
defers[1].resolve() | ||
await defers[2] | ||
}) | ||
}) | ||
|
||
describe('2nd suite', { concurrent: true, concurrentSuite: true }, () => { | ||
test('c', async () => { | ||
await defers[1] | ||
defers[2].resolve() | ||
}) | ||
}) | ||
}) |
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