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

Đang mở
#1,889 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
node.js, nuxt, typescript
Lĩnh vực
testing

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
445
Fork
121
Merge trung bình
3 ngày 11 giờ
Pull request đã merge (30 ngày)
23

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nuxt/test-utils

Tất cả issue của nuxt/test-utils

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.