zerodevx/svelte-toast

Testing library + jest throw an error

Iuriy-Budnikov opened this issue · 1 comments

image

image

<script lang="ts">
  import { onMount } from 'svelte';
  import { SvelteToast } from '@zerodevx/svelte-toast';
  import type { SvelteToastOptions } from '@zerodevx/svelte-toast';
  import cx from 'clsx';
  import type { ClassValue } from 'clsx';
  import { canUseDOM } from '../../../components/utils/exenv';
  import './Toast.scss';
  /**
   * Classname
   */
  export let className: ClassValue = '';
  /**
   * SvelteToastOptions
   */
  export let options: SvelteToastOptions;
  /**
   * SvelteToastOptions target
   */
  export let target: string;
  // svelte toast doesn't support ssr
  let mounted = false;
  onMount(() => {
    if (canUseDOM) {
      mounted = true;
    }
  });
</script>

{#if mounted}
  <div class={cx('toast', className)}>
    <SvelteToast {options} {target} />
  </div>
{/if}

Likely related to #60