e2e setup() leaves its random .nuxt/test/<id> build directory behind after every run

オープン
#1,889 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, nuxt, typescript
領域
testing

調査の方向性

The issue points to loadFixture in the generated dist/e2e-*.mjs and shows the cleanup registration condition. Trace this code to its source and check how loadNuxt() creates the build directory and how teardown runs. Reproduce with the provided Vitest e2e test; done when the test-created random build directory is removed after the test finishes.

索引モデルが issue の本文から書いたものです。

説明

Environment
  • @nuxt/test-utils 4.1.0, nuxt 4.5.2, Node 22.21.1, macOS
What happens

Every run of an e2e test that uses setup({ server: true }) (build mode, no buildDir option) leaves its random build directory, .nuxt/test/<randomId> (about 23 MB for our app), behind after the run finishes. They pile up, one per run.

Why

In loadFixture (dist/e2e-*.mjs), the teardown that removes the build directory is only registered when the directory does not exist after loadNuxt():

ctx.nuxt = await loadNuxt({ ... overrides: ctx.options.nuxtConfig ... })
const buildDir = ctx.nuxt.options.buildDir
if (!existsSync(buildDir)) {
  await promises.mkdir(buildDir, { recursive: true })
  ctx.teardown = ctx.teardown || []
  ctx.teardown.push(() => promises.rm(buildDir, { recursive: true, force: true }))
}

On our app loadNuxt() has already created the directory by that point, so the cleanup is never registered.

Steps to reproduce
  1. In a Nuxt 4 app, add a test:
    // @vitest-environment node
    import { expect, it } from "vitest";
    import { fetch, setup } from "@nuxt/test-utils/e2e";
    await setup({ server: true, browser: false });
    it("serves /", async () => { expect((await fetch("/")).status).toBe(200); });
    
  2. Run it with npx vitest run <file>; it passes.
  3. ls .nuxt/test shows a <randomId> directory left behind. Each further run adds another.
Expected

The build directory created for the test is removed when the test finishes.

主要言語
TypeScript
スター
445
フォーク
121
平均マージ
3日 11時間
マージ済み PR(30日)
23

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nuxt/test-utils のほかの issue

nuxt/test-utils の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。