Skip to content

Commit dda350a

Browse files
committed
more tests
1 parent 58905d5 commit dda350a

File tree

9 files changed

+90
-0
lines changed

9 files changed

+90
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
$effect.pre(() => {
3+
throw new Error('oh noes');
4+
});
5+
</script>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
test({ assert, target, logs }) {
5+
assert.deepEqual(logs, ['error caught']);
6+
assert.htmlEqual(target.innerHTML, `<div>Error!</div><button>Retry</button>`);
7+
}
8+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script>
2+
import Child from './Child.svelte';
3+
</script>
4+
5+
<svelte:boundary onerror={(e) => console.log('error caught')}>
6+
<Child />
7+
8+
{#snippet failed(e, retry)}
9+
<div>Error!</div>
10+
<button onclick={retry}>Retry</button>
11+
{/snippet}
12+
</svelte:boundary>
13+
14+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
$effect.pre(() => {
3+
throw new Error('oh noes');
4+
});
5+
</script>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
test({ assert, target, logs }) {
5+
assert.deepEqual(logs, ['error caught']);
6+
assert.htmlEqual(target.innerHTML, `<div>Error!</div><button>Retry</button>`);
7+
}
8+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script>
2+
import Child from './Child.svelte';
3+
</script>
4+
5+
<svelte:boundary onerror={(e) => console.log('error caught')}>
6+
<!-- boundary should rethrow error as there's no control flow -->
7+
<svelte:boundary>
8+
<Child />
9+
</svelte:boundary>
10+
11+
{#snippet failed(e, retry)}
12+
<div>Error!</div>
13+
<button onclick={retry}>Retry</button>
14+
{/snippet}
15+
</svelte:boundary>
16+
17+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
$effect.pre(() => {
3+
throw new Error('oh noes');
4+
});
5+
</script>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
test({ assert, target, logs }) {
5+
assert.deepEqual(logs, ['error caught']);
6+
assert.htmlEqual(target.innerHTML, `<div>Error!</div><button>Retry</button>`);
7+
}
8+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<script>
2+
import Child from './Child.svelte';
3+
</script>
4+
5+
<svelte:boundary onerror={(e) => console.log('error caught')}>
6+
<!-- boundary should rethrow error as there's no control flow -->
7+
<svelte:boundary>
8+
<!-- rethrow the error in the handler -->
9+
<svelte:boundary onerror={e => { throw e }}>
10+
<Child />
11+
</svelte:boundary>
12+
</svelte:boundary>
13+
14+
{#snippet failed(e, retry)}
15+
<div>Error!</div>
16+
<button onclick={retry}>Retry</button>
17+
{/snippet}
18+
</svelte:boundary>
19+
20+

0 commit comments

Comments
 (0)