-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent dev from crashing when there are errors in template (#5417)
* Prevent dev from crashing when there are errors in template * Adding a changeset
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Prevent dev from crashing when there are errors in template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
import { expect } from 'chai'; | ||
|
||
import { runInContainer } from '../../../dist/core/dev/index.js'; | ||
import { createFs, createRequestAndResponse } from '../test-utils.js'; | ||
import svelte from '../../../../integrations/svelte/dist/index.js'; | ||
import { defaultLogging } from '../../test-utils.js'; | ||
|
||
const root = new URL('../../fixtures/alias/', import.meta.url); | ||
|
||
describe('dev container', () => { | ||
it('should not crash when reassigning a hydrated component', async () => { | ||
const fs = createFs( | ||
{ | ||
'/src/pages/index.astro': ` | ||
--- | ||
import Svelte from '../components/Client.svelte'; | ||
const Foo = Svelte; | ||
const Bar = Svelte; | ||
--- | ||
<html> | ||
<head><title>testing</title></head> | ||
<body> | ||
<Foo client:load /> | ||
<Bar client:load /> | ||
</body> | ||
</html> | ||
` | ||
}, | ||
root | ||
); | ||
|
||
await runInContainer({ | ||
fs, root, | ||
logging: { | ||
...defaultLogging, | ||
// Error is expected in this test | ||
level: 'silent' | ||
}, | ||
userConfig: { | ||
integrations: [svelte()] | ||
} | ||
}, async (container) => { | ||
const { req, res, done } = createRequestAndResponse({ | ||
method: 'GET', | ||
url: '/', | ||
}); | ||
container.handle(req, res); | ||
const html = await done; | ||
expect(res.statusCode).to.equal(200, 'We get a 200 because the error occurs in the template, but we didn\'t crash!'); | ||
}); | ||
}); | ||
}); |