Closed
Description
I made a brief comment on #284 - but I thought I could add a partial reproduction step. I wasn't able to cause this on main
- so I don't know if it's related to svelte5, or the fact that the happy-dom commits haven't been merged. Either way, it took me hours to dig in and debug this - so hopefully this will help anyone else running down this path.
On the svelte5
branch, I created a mostly empty Svelte component:
<!-- EmptyComp.svelte -->
<h1>Hello world!</h1>
and I modified the debug.test.js
to point to this:
import { describe, test } from 'vitest'
import { render } from '..'
import EmptyComp from './fixtures/EmptyComp.svelte'
describe('debug', () => {
test('pretty prints the container', () => {
const { debug } = render(EmptyComp)
debug()
})
})
Running test
using jsdom
, and there are no problems - passes.
Installing the latest happy-dom
and running test
returns this PrettyFormatPluginError.
PrettyFormatPluginError: Cannot read properties of null (reading 'toLowerCase')
❯ Object.serialize node_modules/.pnpm/@testing-library+dom@9.3.4/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:107:77
❯ printPlugin node_modules/.pnpm/pretty-format@27.5.1/node_modules/pretty-format/build/index.js:330:16
❯ printer node_modules/.pnpm/pretty-format@27.5.1/node_modules/pretty-format/build/index.js:379:12
❯ node_modules/.pnpm/@testing-library+dom@9.3.4/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:43:79
❯ printChildren node_modules/.pnpm/@testing-library+dom@9.3.4/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:42:89
❯ Object.serialize node_modules/.pnpm/@testing-library+dom@9.3.4/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:114:75
❯ printPlugin node_modules/.pnpm/pretty-format@27.5.1/node_modules/pretty-format/build/index.js:330:16
❯ printer node_modules/.pnpm/pretty-format@27.5.1/node_modules/pretty-format/build/index.js:379:12
❯ node_modules/.pnpm/@testing-library+dom@9.3.4/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:43:79
What's weird is that, if there are 2 HTML lines in the component, the error goes away 🤦🏽
<!-- EmptyComp.svelte -->
<h1>Hello world!</h1>
<h1>Hello world!</h1>