Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vitest): allow overiding package installer with public API #4936

Merged
merged 3 commits into from Jan 12, 2024

Conversation

sheremet-va
Copy link
Member

Description

Closes #4864

Proposed API:

  • env VITEST_SKIP_INSTALL_CHECKS that disables all install checks - Vitest assumes all dependencies are installed
  • VitestPackageInstaller class with ensureInstalled method (exported via vitest/node) - other implementations can override it if needed and provide a new class to vitestOptions when starting Vitest:
await startVitest('test', [], {}, {}, {
  packageInstaller: new CustomPackageInstaller()
})

cc /@Jinjiang

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Copy link

netlify bot commented Jan 11, 2024

Deploy Preview for fastidious-cascaron-4ded94 canceled.

Name Link
🔨 Latest commit 233492b
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/65a15a1fee76ec0008c5e54d

@sheremet-va sheremet-va merged commit c2cceeb into vitest-dev:main Jan 12, 2024
18 of 19 checks passed
@sheremet-va sheremet-va deleted the feat/package-installer-api branch January 12, 2024 16:04
@Jinjiang
Copy link

@sheremet-va it looks great! May I confirm what would happen if I return false in the ensureInstalled() method?

@sheremet-va
Copy link
Member Author

Depends on the caller. In most situations, it will exit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A Node API to catch deps installation prompts and handle it on the user's own
2 participants