Merge pull request #620 from cudr/error_page_hooks

Error page lifecycle
This commit is contained in:
Rich Harris
2019-04-27 11:06:28 -04:00
committed by GitHub
6 changed files with 85 additions and 21 deletions

View File

@@ -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>

View File

@@ -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');
});
});
});