Describe the bug
Since v2.0.2 and this PR #6077, Vitest uses @vitest/pretty-format which bundles react-is from React 18, but this doesn't support formatting React 19's element.
Previously it was possible to overrides react-is to pin React 19 version like other React deps react, react-dom, and react-server-dom-webpack and it's common to do so.
Not sure what would be the solution. We can try bundling react-is both from 18 and 19 and switch during runtime?
Reproduction
I found the issue on my repo hi-ogawa/vite-plugins#660, which is using pnpm override like this https://github.com/hi-ogawa/vite-plugins/blob/ca3f97ec09c2549d98779acbf9a24e97706c125d/package.json#L43-L46
Stackblitz repro
On latest Vitest https://stackblitz.com/edit/vitest-dev-vitest-a6zqtz?file=test%2Frepro.test.tsx
// repro.test.tsx
import { expect, test } from 'vitest';
test('repro', () => {
expect(<div>hello</div>).toMatchInlineSnapshot(`
{
"$$typeof": Symbol(react.transitional.element),
"_owner": null,
"_store": {},
"key": null,
"props": {
"children": "hello",
},
"type": "div",
}
`);
});
On Vitest v2.0.1 https://stackblitz.com/edit/vitest-dev-vitest-rrglpy?file=test%2Frepro.test.tsx
test('repro', () => {
expect(<div>hello</div>).toMatchInlineSnapshot(`
<div>
hello
</div>
`);
});
System Info
(stackblitz)
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.20.3 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.3 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
vitest: 2.1.5 => 2.1.5
Used Package Manager
npm
Validations
Describe the bug
Since v2.0.2 and this PR #6077, Vitest uses
@vitest/pretty-formatwhich bundlesreact-isfrom React 18, but this doesn't support formatting React 19's element.Previously it was possible to overrides
react-isto pin React 19 version like other React depsreact,react-dom, andreact-server-dom-webpackand it's common to do so.Not sure what would be the solution. We can try bundling
react-isboth from 18 and 19 and switch during runtime?Reproduction
I found the issue on my repo hi-ogawa/vite-plugins#660, which is using pnpm override like this https://github.com/hi-ogawa/vite-plugins/blob/ca3f97ec09c2549d98779acbf9a24e97706c125d/package.json#L43-L46
Stackblitz repro
On latest Vitest https://stackblitz.com/edit/vitest-dev-vitest-a6zqtz?file=test%2Frepro.test.tsx
On Vitest v2.0.1 https://stackblitz.com/edit/vitest-dev-vitest-rrglpy?file=test%2Frepro.test.tsx
System Info
(stackblitz) System: OS: Linux 5.0 undefined CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 0 Bytes / 0 Bytes Shell: 1.0 - /bin/jsh Binaries: Node: 18.20.3 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 10.2.3 - /usr/local/bin/npm pnpm: 8.15.6 - /usr/local/bin/pnpm npmPackages: vitest: 2.1.5 => 2.1.5Used Package Manager
npm
Validations