|
1 | 1 | import { createRequestHandler } from "../../lib/server-runtime/server"; |
2 | 2 | import { ErrorResponseImpl } from "../../lib/router/utils"; |
3 | 3 | import { mockServerBuild } from "./utils"; |
4 | | -import type { |
5 | | - HandleDocumentRequestFunction, |
6 | | - ServerBuild, |
7 | | -} from "../../lib/server-runtime/build"; |
| 4 | +import type { HandleDocumentRequestFunction } from "../../lib/server-runtime/build"; |
8 | 5 |
|
9 | 6 | function getHandler( |
10 | 7 | routeModule = {}, |
@@ -160,50 +157,29 @@ describe("handleError", () => { |
160 | 157 | let error = new Error("💥"); |
161 | 158 |
|
162 | 159 | let handleErrorSpy = jest.fn(); |
163 | | - let build: ServerBuild = { |
164 | | - routes: { |
165 | | - param: { |
166 | | - id: "param", |
167 | | - path: "/:param", |
168 | | - module: { |
169 | | - default() { |
170 | | - return null; |
171 | | - }, |
172 | | - loader() { |
173 | | - throw error; |
174 | | - }, |
| 160 | + let build = mockServerBuild( |
| 161 | + { |
| 162 | + root: { |
| 163 | + path: "", |
| 164 | + default() { |
| 165 | + return null; |
175 | 166 | }, |
176 | 167 | }, |
177 | | - }, |
178 | | - entry: { |
179 | | - module: { |
180 | | - handleError: handleErrorSpy, |
| 168 | + param: { |
| 169 | + path: ":param", |
| 170 | + parentId: "root", |
181 | 171 | default() { |
182 | | - return new Response("<html><body>Dummy document</body></html>"); |
| 172 | + return null; |
| 173 | + }, |
| 174 | + loader() { |
| 175 | + throw error; |
183 | 176 | }, |
184 | 177 | }, |
185 | 178 | }, |
186 | | - routeDiscovery: { |
187 | | - mode: "lazy", |
188 | | - manifestPath: "/__manifest", |
189 | | - }, |
190 | | - future: { |
191 | | - // Fill in the required values |
192 | | - unstable_middleware: false, |
193 | | - unstable_subResourceIntegrity: false, |
194 | | - }, |
195 | | - prerender: [], |
196 | | - assets: { |
197 | | - entry: { imports: [], module: "" }, |
198 | | - routes: {}, |
199 | | - url: "", |
200 | | - version: "", |
201 | | - }, |
202 | | - assetsBuildDirectory: "", |
203 | | - publicPath: "/", |
204 | | - ssr: true, |
205 | | - isSpaMode: false, |
206 | | - }; |
| 179 | + { |
| 180 | + handleError: handleErrorSpy, |
| 181 | + } |
| 182 | + ); |
207 | 183 |
|
208 | 184 | let handler = createRequestHandler(build); |
209 | 185 | let request = new Request("http://example.com/a.data"); |
|
0 commit comments