[email protected]: experimental_AstroContainer output now includes data-astro-source-* dev annotations (regression from #17736)
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
// vitest.config.ts
import { getViteConfig } from 'astro/config';
export default getViteConfig({ test: { environment: 'node' } });---
// Hello.astro
---
<button type="submit" id="go">Go</button>// 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.4OK) - vitest
5.0.2, config viagetViteConfig - Node 24
Source: withastro/astro