From e3cddb433d8b15cafafe4ee3cc1eade3a15cd2ec Mon Sep 17 00:00:00 2001 From: wulinsheng123 <409187100@qq.com> Date: Thu, 3 Nov 2022 23:31:26 +0800 Subject: [PATCH] chore: fix tests in node 18 (#5266) --- .gitignore | 1 + packages/astro/test/test-utils.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 8ce8095bca..0f5c682847 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ scripts/memory/project/src/pages/ package-lock.json .turbo/ .eslintcache +.pnpm-store # ignore top-level vscode settings /.vscode/settings.json diff --git a/packages/astro/test/test-utils.js b/packages/astro/test/test-utils.js index 45ecabd523..29527df72c 100644 --- a/packages/astro/test/test-utils.js +++ b/packages/astro/test/test-utils.js @@ -70,6 +70,14 @@ export async function loadFixture(inlineConfig) { if (!inlineConfig || !inlineConfig.root) throw new Error("Must provide { root: './fixtures/...' }"); + // Compatible with different Node versions (https://vitejs.dev/guide/migration.html#dev-server-changes) + // TODO: Remove this to test in Node >= 17 where the dns resolver is verbatim + if (!inlineConfig?.server) { + inlineConfig.server = { + host: '127.0.0.1' + } + } + // load config let cwd = inlineConfig.root; delete inlineConfig.root;