summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/astro/src/runtime/server/render/astro.ts12
-rw-r--r--packages/astro/test/units/dev/hydration.test.js44
2 files changed, 31 insertions, 25 deletions
diff --git a/packages/astro/src/runtime/server/render/astro.ts b/packages/astro/src/runtime/server/render/astro.ts
index 9d28a6f81..3283669c0 100644
--- a/packages/astro/src/runtime/server/render/astro.ts
+++ b/packages/astro/src/runtime/server/render/astro.ts
@@ -4,9 +4,9 @@ import type { RenderInstruction } from './types';
import { HTMLBytes, markHTMLString } from '../escape.js';
import { HydrationDirectiveProps } from '../hydration.js';
+import { isPromise } from '../util.js';
import { renderChild } from './any.js';
import { HTMLParts } from './common.js';
-import { isPromise } from '../util.js';
// In dev mode, check props and make sure they are valid for an Astro component
function validateComponentProps(props: any, displayName: string) {
@@ -32,20 +32,20 @@ export class AstroComponent {
constructor(htmlParts: TemplateStringsArray, expressions: any[]) {
this.htmlParts = htmlParts;
this.error = undefined;
- this.expressions = expressions.map(expression => {
+ this.expressions = expressions.map((expression) => {
// Wrap Promise expressions so we can catch errors
// There can only be 1 error that we rethrow from an Astro component,
// so this keeps track of whether or not we have already done so.
- if(isPromise(expression)) {
- return Promise.resolve(expression).catch(err => {
- if(!this.error) {
+ if (isPromise(expression)) {
+ return Promise.resolve(expression).catch((err) => {
+ if (!this.error) {
this.error = err;
throw err;
}
});
}
return expression;
- })
+ });
}
get [Symbol.toStringTag]() {
diff --git a/packages/astro/test/units/dev/hydration.test.js b/packages/astro/test/units/dev/hydration.test.js
index d1ae0460c..0fb10ffda 100644
--- a/packages/astro/test/units/dev/hydration.test.js
+++ b/packages/astro/test/units/dev/hydration.test.js
@@ -1,4 +1,3 @@
-
import { expect } from 'chai';
import { runInContainer } from '../../../dist/core/dev/index.js';
@@ -25,29 +24,36 @@ describe('dev container', () => {
<Bar client:load />
</body>
</html>
- `
+ `,
},
root
);
- await runInContainer({
- fs, root,
- logging: {
- ...defaultLogging,
- // Error is expected in this test
- level: 'silent'
+ await runInContainer(
+ {
+ fs,
+ root,
+ logging: {
+ ...defaultLogging,
+ // Error is expected in this test
+ level: 'silent',
+ },
+ userConfig: {
+ integrations: [svelte()],
+ },
},
- 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!"
+ );
}
- }, 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!');
- });
+ );
});
});