Replies: 1 comment
-
|
In JSDOM-based tests (vitest + @testing-library/svelte), import { render } from '@testing-library/svelte';
import MyComponent from './MyComponent.svelte';
test('renders head content', async () => {
render(MyComponent);
// Wait for async rendering if needed
await new Promise(r => setTimeout(r, 0));
expect(document.head.querySelector('meta[name="description"]')).toBeTruthy();
});Ensure |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This is perhaps a silly question, but it's something I ran into at work.
We have a couple of components which are using JS libraries to defer the displaying of some content within our written articles and blogs.
There is also a unit test, broken down to it's very basic pieces, you get something that looks like this:
In practice, this works fine when testing on a browser, but someone well before I got there created a test that looks something like this
Which fails, and writing the entire DOM to the console shows me
It seems that in svelte 5 (I haven't been able to test on svelte 4) the
<svelte:head>contents are not being applied in test environments.Anyone got any ideas how I can fix this?
Beta Was this translation helpful? Give feedback.
All reactions