Skip to content

fix: declare vitest as an optional peer dependency - #733

Merged
gnapse merged 2 commits into
testing-library:mainfrom
big-mon:fix/vitest-peer-dependency
Aug 9, 2026
Merged

gnapse merged 2 commits into
testing-library:mainfrom
big-mon:fix/vitest-peer-dependency

Conversation

@big-mon

@big-mon big-mon commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

What:

Declare vitest as an optional peer dependency.

Fixes #662.

Why:

The @testing-library/jest-dom/vitest entry point imports vitest at runtime, but vitest is currently only a development dependency. Strict dependency layouts therefore cannot resolve the import from jest-dom, even when the consuming project directly depends on both packages.

This is reproducible with pnpm 11's global virtual store using @testing-library/[email protected] and [email protected]:

Error: Cannot find package 'vitest' imported from .../@testing-library/jest-dom/dist/vitest.mjs

Keeping the peer optional avoids requiring or installing Vitest for Jest/Bun consumers. The range restores the previously supported >= 0.32 contract.

How:

  • Add vitest to peerDependencies as >= 0.32.
  • Mark the peer optional in peerDependenciesMeta.
  • Add a regression test for the published package metadata.

A packed build was also installed into a fresh pnpm 11 project with enableGlobalVirtualStore: true; pnpm bound the consumer's [email protected] to jest-dom, and the Vitest setup import passed without packageExtensions.

Checklist:

  • Documentation N/A
  • Tests
  • Updated Type Definitions N/A
  • Ready to be merged

@gnapse gnapse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment thread src/__tests__/package-json.js Outdated
@gnapse gnapse self-assigned this Aug 8, 2026
@gnapse
gnapse enabled auto-merge (squash) August 9, 2026 23:39
@gnapse
gnapse merged commit 3782c78 into testing-library:main Aug 9, 2026
3 checks passed
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 7.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

736-c41-2c1-e464fc974 pushed a commit to Swiss-Armed-Forces/Loom that referenced this pull request Sep 29, 2026
This MR contains the following updates:

| Package | Type | Update | Change | OpenSSF |
|---|---|---|---|---|
| [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) | devDependencies | major | [`^6.9.1` → `^7.0.0`](https://renovatebot.com/diffs/npm/@testing-library%2fjest-dom/6.9.1/7.0.1) | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/testing-library/jest-dom/badge)](https://securityscorecards.dev/viewer/?uri=github.com/testing-library/jest-dom) |

---

### Release Notes

<details>
<summary>testing-library/jest-dom (@&#8203;testing-library/jest-dom)</summary>

### [`v7.0.1`](https://github.com/testing-library/jest-dom/releases/tag/v7.0.1)

[Compare Source](testing-library/jest-dom@v7.0.0...v7.0.1)

##### Bug Fixes

- declare vitest as an optional peer dependency ([#&#8203;733](testing-library/jest-dom#733)) ([3782c78](testing-library/jest-dom@3782c78))

### [`v7.0.0`](https://github.com/testing-library/jest-dom/releases/tag/v7.0.0)

[Compare Source](testing-library/jest-dom@v6.10.0...v7.0.0)

##### Features

- add toContainAnyBy\* and toContainOneBy\* query matchers ([1e39089](testing-library/jest-dom@1e39089))

##### BREAKING CHANGES

- [@&#8203;testing-library/dom](https://github.com/testing-library/dom) is now a required peer dependency. The minimum supported
  Node.js version is now 22.

Repaired release for [#&#8203;731](testing-library/jest-dom#731)

### [`v6.10.0`](https://github.com/testing-library/jest-dom/releases/tag/v6.10.0)

[Compare Source](testing-library/jest-dom@v6.9.1...v6.10.0)

##### Features

- add toContainAnyBy\* and toContainOneBy\* query matchers ([#&#8203;731](testing-library/jest-dom#731)) ([cae44df](testing-library/jest-dom@cae44df))

</details>

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC41My4wIiwidXBkYXRlZEluVmVyIjoiNDQuMTE3LjEiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbImRlcGVuZGVuY2llcyIsInJlbm92YXRlIl19-->

See merge request swiss-armed-forces/cyber-command/cea/loom!778

Co-authored-by: Loom MR Pipeline Trigger <group_103951964_bot_9504bb8dead6d4e406ad817a607f24be@noreply.gitlab.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot find package 'vitest'

2 participants