Closed
Description
Version: v16.5.2
The following test should pass but does not.
import {expect, test} from "bun:test";
import {Window} from "happy-dom";
test("showcase", (): undefined =>
{
const window: Window = new Window();
//@ts-expect-error
global.window = window;
//@ts-expect-error
global.document = window.document;
localStorage.clear();
document.body.innerHTML = ` <div>
<button class="btn btn-secondary comment_reply" data-id="{{id}}" type=
"button">{{message_gui_reply}}</button> <button class="btn btn-secondary comment_collapse
visually-hidden" type="button">{{message_gui_replies}}</button>
</div>`;
console.log(document.body.outerHTML);
const tmp: Element | null = document.querySelector("div > .comment_collapse");
expect(tmp).not.toBeNull();
});
Output:
tests/src-web/typescript/comment.test.ts:
<body> <div>
<button class="btn btn-secondary comment_reply" data-id="{{id}}" type="button">{{message_gui_reply}}</button> <button class="btn btn-secondary comment_collapse
 visually-hidden" type="button">{{message_gui_replies}}</button>
</div></body>
19 | </div>`;
20 |
21 | console.log(document.body.outerHTML);
22 |
23 | const tmp: Element | null = document.querySelector("div > .comment_collapse");
24 | expect(tmp).not.toBeNull();
^
error: expect(received).not.toBeNull()
Received: null
at /home/matheus/programmieren/c++/argo/tests/src-web/typescript/comment.test.ts:24:21
✗ showcase [12.20ms]
The error is obviously that the class which is followed by a line break is targeted but is modified to comment_collapse

during parsing.