From 22e405a04491aba47a7f172e7b0ee103fe5babe5 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Thu, 5 Dec 2024 11:25:49 +0000 Subject: [PATCH] fix: use correct datastore location in test environment (#12640) --- .changeset/violet-bugs-enjoy.md | 5 +++++ .../astro/src/content/vite-plugin-content-virtual-mod.ts | 6 ++---- packages/astro/src/core/dev/dev.ts | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 .changeset/violet-bugs-enjoy.md diff --git a/.changeset/violet-bugs-enjoy.md b/.changeset/violet-bugs-enjoy.md new file mode 100644 index 0000000000..bdc476308e --- /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 01dfc3fc81..30c703b5c2 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 72a173dbe4..0af6371647 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