We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 66c9f45 commit 801d80cCopy full SHA for 801d80c
src/__tests__/fixtures/onMount.svelte
@@ -0,0 +1,12 @@
1
+<div data-testid="target">{message}</div>
2
+
3
+<script>
4
+ import { onMount } from 'svelte';
5
6
+ let message = "not yet";
7
8
+ onMount( () => {
9
+ message = 'nailed it';
10
+ });
11
12
+</script>
src/__tests__/onMount.test.js
@@ -0,0 +1,18 @@
+import { expect, test, vi } from 'vitest'
+import { render } from '..'
+import Comp from './fixtures/onMount.svelte'
+vi.mock('svelte', async () => {
+ const actual = await vi.importActual('svelte')
+ return {
+ ...actual,
+ onMount: (await import('svelte/internal')).onMount,
+ }
+})
13
14
+test('pretty prints the container', () => {
15
+ const { getByTestId } = render(Comp)
16
17
+ expect(getByTestId('target').innerHTML).toEqual('nailed it')
18
0 commit comments