diff --git a/.changeset/ninety-cups-decide.md b/.changeset/ninety-cups-decide.md new file mode 100644 index 0000000000..3a637fc866 --- /dev/null +++ b/.changeset/ninety-cups-decide.md @@ -0,0 +1,22 @@ +--- +'astro': patch +--- + +Adds a new function called `insertPageRoute` to the Astro Container API. + +The new function is useful when testing routes that, for some business logic, use `Astro.rewrite`. + +For example, if you have a route `/blog/post` and for some business decision there's a rewrite to `/generic-error`, the container API implementation will look like this: + +```js +import Post from "../src/pages/Post.astro"; +import GenericError from "../src/pages/GenericError.astro"; +import { experimental_AstroContainer as AstroContainer } from "astro/container"; + +const container = await AstroContainer.create(); +container.insertPageRoute("/generic-error", GenericError); +const result = await container.renderToString(Post); +console.log(result) // this should print the response from GenericError.astro +``` + +This new method only works for page routes, which means that endpoints aren't supported. diff --git a/packages/astro/e2e/fixtures/actions-blog/src/components/PostComment.tsx b/packages/astro/e2e/fixtures/actions-blog/src/components/PostComment.tsx index 4d93e310d7..4c763b2cab 100644 --- a/packages/astro/e2e/fixtures/actions-blog/src/components/PostComment.tsx +++ b/packages/astro/e2e/fixtures/actions-blog/src/components/PostComment.tsx @@ -18,7 +18,7 @@ export function PostComment({