#18162·astro

[email protected]: experimental_AstroContainer output now includes data-astro-source-* dev annotations (regression from #17736)

Author: atomanticCreated Sep 28, 2026Updated Sep 28, 2026
Labelspkg: astro- P3: minor bugtriage: fix pending

Description

Since [email protected], HTML rendered through experimental_AstroContainer.renderToString() includes dev-time source annotations (data-astro-source-file="…" / data-astro-source-loc="…") on every element, when the component is imported the regular way (no ?container query) and rendered under Vitest via getViteConfig from astro/config.

[email protected] does not emit these attributes in the same setup, so this looks like a regression introduced by #17736 (renderComponent() / the ?container query import).

Production astro build output is not affected — the annotations only leak into the container API's render output in the test pipeline.

Reproduction

typescript
// vitest.config.ts
import { getViteConfig } from 'astro/config';
export default getViteConfig({ test: { environment: 'node' } });
astro
---
// Hello.astro
---
<button type="submit" id="go">Go</button>
typescript
// hello.test.ts
import { experimental_AstroContainer } from 'astro/container';
import { expect, test } from 'vitest';
import Hello from './Hello.astro';

test('container output has no dev annotations', async () => {
  const container = await experimental_AstroContainer.create();
  const html = await container.renderToString(Hello);
  expect(html).toBe('<button type="submit" id="go">Go</button>');
});
  • astro 7.3.4: passes
  • astro 7.3.5: fails — received <button type="submit" id="go" data-astro-source-file="/path/to/repo/src/components/Hello.astro" data-astro-source-loc="2:0">Go</button>

Impact

Any suite asserting exact markup emitted by AstroContainer (the documented way to test what a component emits) breaks on a patch bump. Workaround is pinning 7.3.4.

Environment

  • astro 7.3.5 (regression; 7.3.4 OK)
  • vitest 5.0.2, config via getViteConfig
  • Node 24