Skip to content

Commit

Permalink
fix: integration test cases (#5789)
Browse files Browse the repository at this point in the history
  • Loading branch information
yimingjfe committed May 31, 2024
1 parent 85ac453 commit c0f19eb
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { isRouteErrorResponse, useRouteError } from '@modern-js/runtime/router';

const ErrorBoundary = () => {
const error = useRouteError() as Error;
console.log('isRouteErrorResponse', isRouteErrorResponse(error));
return (
<div>
<div className="error">
<h2>
{isRouteErrorResponse(error)
? JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { isRouteErrorResponse, useRouteError } from '@modern-js/runtime/router';

const ErrorBoundary = () => {
const error = useRouteError() as Error;
console.log('isRouteErrorResponse', isRouteErrorResponse(error));
return (
<div>
<div className="error">
<h2>
{isRouteErrorResponse(error)
? JSON.stringify({
Expand Down
12 changes: 1 addition & 11 deletions tests/integration/ssr/tests/__snapshots__/base-json.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Traditional SSR in json data error thrown in client navigation 1`] = `
CDPPage {
"emitter": {
"all": Map {},
"emit": [Function],
"off": [Function],
"on": [Function],
},
"eventsMap": Map {},
}
`;
exports[`Traditional SSR in json data error thrown in client navigation 1`] = `"{"status":500,"statusText":"Internal Server Error","data":{"messsage":"error occurs"}}"`;
12 changes: 1 addition & 11 deletions tests/integration/ssr/tests/__snapshots__/base.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Traditional SSR error thrown in client navigation 1`] = `
CDPPage {
"emitter": {
"all": Map {},
"emit": [Function],
"off": [Function],
"on": [Function],
},
"eventsMap": Map {},
}
`;
exports[`Traditional SSR error thrown in client navigation 1`] = `"{"status":500,"statusText":"Internal Server Error","data":{"messsage":"error occurs"}}"`;
5 changes: 4 additions & 1 deletion tests/integration/ssr/tests/base-json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ async function errorThrownInClientNavigation(page: Page, appPort: number) {
});

await page.click('#error-btn');
await (expect(page) as any).toMatchSnapshot();
await page.waitForSelector('.error');
const element = await page.$('.error');
const elementContent = await page.evaluate(el => el?.textContent, element);
expect(elementContent).toMatchSnapshot();
}

async function redirectInLoader(page: Page, appPort: number) {
Expand Down
5 changes: 4 additions & 1 deletion tests/integration/ssr/tests/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ async function errorThrownInClientNavigation(page: Page, appPort: number) {
});

await page.click('#error-btn');
await (expect(page) as any).toMatchSnapshot();
await page.waitForSelector('.error');
const element = await page.$('.error');
const elementContent = await page.evaluate(el => el?.textContent, element);
expect(elementContent).toMatchSnapshot();
}

async function redirectInLoader(page: Page, appPort: number) {
Expand Down

0 comments on commit c0f19eb

Please sign in to comment.