You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, everyone. I have a Sveltekit project with Svelte v5. It has Vitest, jsdom and @testing-library/svelte installed and working. I can use the render() function from @testing-library/svelte without issues.
However, the project I'm working on has a lifecycle that requires me to mount the component without the use of render(): Mounting the component is done within the library code using Svelte's mount() function. I need the "real thing" because the unit test is meant to update the props of the mounted component (by calling the function I'm unit-testing) and then it must assert that the component receives them. I am planning to assert this by mounting the component, then using screen from @testing-library/svelte to check on the effect of the property change.
Well, my problem: mount() throws the error "mount(...) is not available on the server". So even though jsdome is properly set because it works in other unit tests, the code for this unit test is not fooling mount(). If anyone could help me fix this, or alternatively give me an alternative way to unit-test the property change, I would be grateful.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, everyone. I have a Sveltekit project with Svelte v5. It has Vitest, jsdom and @testing-library/svelte installed and working. I can use the
render()
function from @testing-library/svelte without issues.However, the project I'm working on has a lifecycle that requires me to mount the component without the use of
render()
: Mounting the component is done within the library code using Svelte'smount()
function. I need the "real thing" because the unit test is meant to update the props of the mounted component (by calling the function I'm unit-testing) and then it must assert that the component receives them. I am planning to assert this by mounting the component, then usingscreen
from @testing-library/svelte to check on the effect of the property change.Well, my problem:
mount()
throws the error "mount(...) is not available on the server". So even though jsdome is properly set because it works in other unit tests, the code for this unit test is not foolingmount()
. If anyone could help me fix this, or alternatively give me an alternative way to unit-test the property change, I would be grateful.Beta Was this translation helpful? Give feedback.
All reactions