diff --git a/.changeset/violet-bugs-enjoy.md b/.changeset/violet-bugs-enjoy.md new file mode 100644 index 000000000000..bdc476308ec4 --- /dev/null +++ b/.changeset/violet-bugs-enjoy.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes a bug that caused content collections to be returned empty when run in a test environment diff --git a/packages/astro/src/content/vite-plugin-content-virtual-mod.ts b/packages/astro/src/content/vite-plugin-content-virtual-mod.ts index 01dfc3fc8138..30c703b5c22f 100644 --- a/packages/astro/src/content/vite-plugin-content-virtual-mod.ts +++ b/packages/astro/src/content/vite-plugin-content-virtual-mod.ts @@ -50,14 +50,12 @@ export function astroContentVirtualModPlugin({ settings, fs, }: AstroContentVirtualModPluginParams): Plugin { - let IS_DEV = false; let dataStoreFile: URL; return { name: 'astro-content-virtual-mod-plugin', enforce: 'pre', - configResolved(config) { - IS_DEV = !config.isProduction; - dataStoreFile = getDataStoreFile(settings, IS_DEV); + config(_, env) { + dataStoreFile = getDataStoreFile(settings, env.command === 'serve'); }, async resolveId(id) { if (id === VIRTUAL_MODULE_ID) { diff --git a/packages/astro/src/core/dev/dev.ts b/packages/astro/src/core/dev/dev.ts index 72a173dbe462..0af637164735 100644 --- a/packages/astro/src/core/dev/dev.ts +++ b/packages/astro/src/core/dev/dev.ts @@ -107,7 +107,7 @@ export default async function dev(inlineConfig: AstroInlineConfig): Promise