[ci] format
This commit is contained in:
parent
a9f7ff9667
commit
d017701ae6
2 changed files with 31 additions and 25 deletions
|
@ -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]() {
|
||||
|
|
|
@ -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!');
|
||||
});
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue