Skip to content

Astro v5.15+ broke AstroContainer renderToString with"No valid renderer was found for this file extension." #14887

Description

@danawoodman

Astro Info

Astro                    v5.14.8
Node                     v24.6.0
System                   macOS (arm64)
Package Manager          bun
Output                   static
Adapter                  @astrojs/cloudflare
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

na

Describe the Bug

Using astro 5.14.8, using the experimental AstroContainer to render an astro component works. Upgrading to anything from 5.15 and above breaks with this error:

 ❯  astro  src/components/foo.astro.test.ts (1 test | 1 failed) 10ms
   × foo 9ms
     → Unable to render ``.

No valid renderer was found for this file extension.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL   astro  src/components/foo.astro.test.ts > foo
NoMatchingRenderer: Unable to render ``.

No valid renderer was found for this file extension.
 ❯ renderFrameworkComponent ../../node_modules/astro/dist/runtime/server/render/component.js:176:15
    174|       const plural = validRenderers.length > 1;
    175|       if (matchingRenderers.length === 0) {
    176|         throw new AstroError({
       |               ^
    177|           ...AstroErrorData.NoMatchingRenderer,
    178|           message: AstroErrorData.NoMatchingRenderer.message(
 ❯ renderComponentToString ../../node_modules/astro/dist/runtime/server/render/component.js:419:28
 ❯ renderPage ../../node_modules/astro/dist/runtime/server/render/page.js:11:17
 ❯ lastNext ../../node_modules/astro/dist/core/render-context.js:209:25
 ❯ NOOP_MIDDLEWARE_FN ../../node_modules/astro/dist/core/middleware/noop-middleware.js:3:20
 ❯ callMiddleware ../../node_modules/astro/dist/core/middleware/callMiddleware.js:11:10
 ❯ RenderContext.render ../../node_modules/astro/dist/core/render-context.js:243:22
 ❯ experimental_AstroContainer.renderToString ../../node_modules/astro/dist/container/index.js:242:22
 ❯ src/components/foo.astro.test.ts:7:18

example code:

import Foo from "./Foo.astro";
import { experimental_AstroContainer as AstroContainer } from "astro/container";

test("foo", async () => {
  const container = await AstroContainer.create();
  const result = await container.renderToString(Foo);
  document.body.innerHTML = result;
  expect(document.body.innerHTML).toBe("hi");
});

Foo.astro is just a file with the string hi.

This clearly breaks at some point from 5.15 onwards even tho the docs make it seem this code should work out of the box.

What's the expected result?

tests to pass

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-41sygse5

To reproduce, run npm install astro@5.14 to fix the error or npm install astro@5.15 to reproduce the error, then run npm test

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions