Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
adiguba committed Feb 24, 2025
1 parent 2bbebb6 commit a85e1a1
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { flushSync } from 'svelte';
import { test } from '../../test';

// https://github.com/sveltejs/svelte/issues/15368
export default test({
compileOptions: {
dev: true
},

mode: ['client'],

html: `
<p>BOOM</p>
<p>BOOM</p>
<div>OK</div>
<div>OK</div>
`,

async test({ target, assert, component }) {
component.ok = false;
flushSync();

assert.htmlEqual(
target.innerHTML,
`
<p>BOOM</p>
<p>BOOM</p>
<p>BOOM</p>
<p>BOOM</p>
`
);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<script>
let { ok = true } = $props();
function throwError() {
throw new Error();
}
function throwErrorOnUpdate() {
if (ok) {
return "OK";
} else {
fail();
}
}
</script>

<svelte:boundary>
<div>{throwError()}</div>

{#snippet failed()}
<p>BOOM</p>
{/snippet}
</svelte:boundary>

<svelte:boundary>
{@const result = throwError()}
<div>{result}</div>

{#snippet failed()}
<p>BOOM</p>
{/snippet}
</svelte:boundary>

<svelte:boundary>
<div>{throwErrorOnUpdate()}</div>

{#snippet failed()}
<p>BOOM</p>
{/snippet}
</svelte:boundary>

<svelte:boundary>
{@const result = throwErrorOnUpdate()}
<div>{result}</div>

{#snippet failed()}
<p>BOOM</p>
{/snippet}
</svelte:boundary>

0 comments on commit a85e1a1

Please sign in to comment.