mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 03:05:12 +00:00
Merge pull request #620 from cudr/error_page_hooks
Error page lifecycle
This commit is contained in:
@@ -1,3 +1,17 @@
|
||||
<script>
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
|
||||
export let status, error = {};
|
||||
|
||||
let mounted = false;
|
||||
|
||||
onMount(() => {
|
||||
mounted = 'success';
|
||||
})
|
||||
</script>
|
||||
|
||||
<h1>{status}</h1>
|
||||
|
||||
<p>{error.message}</p>
|
||||
<h2>{mounted}</h2>
|
||||
|
||||
<p>{error.message}</p>
|
||||
|
||||
@@ -112,6 +112,17 @@ describe('errors', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('execute error page hooks', async () => {
|
||||
await page.goto(`${base}/some-throw-page`);
|
||||
await start();
|
||||
await wait(50);
|
||||
|
||||
assert.equal(
|
||||
await page.$eval('h2', node => node.textContent),
|
||||
'success'
|
||||
);
|
||||
})
|
||||
|
||||
it('does not serve error page for async non-page error', async () => {
|
||||
await page.goto(`${base}/async-throw.json`);
|
||||
|
||||
@@ -134,4 +145,4 @@ describe('errors', function() {
|
||||
await wait(50);
|
||||
assert.equal(await title(), 'No error here');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user