feat!: add support for pool and poolOptions#4172
Merged
sheremet-va merged 1 commit intovitest-dev:mainfrom Oct 2, 2023
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introduces two new configuration options:
poolandpoolOptions. In #3925 configuring pools became too complex: #3925 (comment). This PR opens up easier API for such cases. Most users won't need these so good defaults are available as before.In future we might open up an API for custom pools. This PR should have compatible API for such case.
Pool
Select pool which use to run tests in. Available values are
'threads'|'forks'|'vmThreads'. Defaults to'threads'.'forks'be'child_process'instead? Or'processes'or'subprocesses'?child_process#3925 we can createvmForksquite easilyPool Options
Specify options for each pool. API shape is similar as
environment + environmentOptions.BREAKING CHANGES
--no-threadsran tests in a singlechild_processwithout isolating test context. Equivalent option is now--pool forks --poolOptions.forks.isolate false. See feat!: support multiple parallelchild_process#3925 for more information about newchild_processusage.--threadsis now--pool=threads--no-threadsis now--pool=forks--single-threadis now--poolOptions.threads.singleThread--experimental-vm-threadsis now--pool=vmThreads--experimental-vm-worker-memory-limitis now--poolOptions.vmThreads.memoryLimit--isolateis now--poolOptions.<pool-name>.isolateandbrowser.isolatetest.maxThreadsis nowtest.poolOptions.<pool-name>.maxThreadstest.minThreadsis nowtest.poolOptions.<pool-name>.minThreadstest.useAtomicsis nowtest.poolOptions.<pool-name>.useAtomicstest.poolMatchGlobs.child_processis nowtest.poolMatchGlobs.forkstest.poolMatchGlobs.experimentalVmThreadsis nowtest.poolMatchGlobs.vmThreadsMigration examples
Details
{ scripts: { - "test": "vitest --no-threads" // For identical behaviour: + "test": "vitest --pool forks --poolOptions.forks.singleFork" // Or multi parallel forks: + "test": "vitest --pool forks" } }{ scripts: { - "test": "vitest --experimental-vm-threads" + "test": "vitest --pool vmThreads" } }{ scripts: { - "test": "vitest --isolate false" + "test": "vitest --poolOptions.threads.isolate false" } }{ scripts: { - "test": "vitest --no-threads --isolate false" + "test": "vitest --pool forks --poolOptions.forks.isolate false" } }Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.