Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How I can test dynamic import with svelte #253

Closed
AdaltonLeite opened this issue Jul 27, 2023 · 2 comments
Closed

How I can test dynamic import with svelte #253

AdaltonLeite opened this issue Jul 27, 2023 · 2 comments

Comments

@AdaltonLeite
Copy link

Hi guys,

Has anyone tried testing dynamic imports with svelte?

I have the following scenario:

<script lang="ts">
let Component: ComponentType<SvelteComponentTyped<Component>>;
onMount(async () => {
    Component = (await import('../../../component')).Default;
  });
</script>

<svelte:component this={Component} ... />

In my test when I try to render this dynamic component it always fails and in the output I realize that it does not even render the component in fact, it seems that it does not wait for the promise to be resolved, has anyone gone through this or has any suggestions?

@yanick
Copy link
Collaborator

yanick commented Jul 27, 2023

I think this is #222 rearing its ugly head. The short of it is: onMount() is not called in a SSR context.

@yanick
Copy link
Collaborator

yanick commented Jan 23, 2024

There was no reply from the original poster, so I'll indeed chalk it up to #222 and close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants