feat: add a built-output smoke test command (`nuxt preview --smoke`)

Aperta
#1,661 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
bun, node.js, typescript
Ambito
cli, testing

Direzione di ricerca

Read the existing nuxt preview command and the described ~550-line Bun smoke script to map how the built server is started and checked. Then trace how the CLI resolves the .output entry and handles environment and signals across runtimes. Done means a smoke command checks HTTP expectations and shutdown, exits nonzero on failure, and leaves no server process running.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

nuxt preview starts .output/server/index.mjs, but it does not verify that the built output:

  • boots with the production environment,
  • serves the shell and all required assets/chunks,
  • starts with the intended runtime (Bun or Node),
  • runs Nitro close hooks and exits cleanly on SIGTERM/SIGINT.

nuxt build can pass while the deploy fails at runtime: a missing secret, a wrong database path, a missing asset, a preset regression (for example the Bun preset skipping close hooks), or a shutdown that hangs. We currently maintain a ~550-line smoke script for this.

What our script does:

  • reserves a free port, creates temporary SQLite databases, and applies migrations;
  • builds a minimal environment instead of inheriting the developer .env;
  • spawns .output/server/index.mjs with Bun;
  • waits for HTTP 200 and a known shell marker, and scans captured logs for forbidden content;
  • sends SIGTERM, asserts exit within 15 seconds and clean shutdown; on Windows it records that Bun's SIGTERM is termination-only;
  • is the last step of check -> build -> built-output Playwright -> smoke.

Proposal: nuxt preview --smoke (or nuxt build --smoke) with:

  • --url / --expect for a path plus expected status and optional body marker;
  • --timeout and --signal;
  • --env-file or --env for a minimal production environment;
  • an assertion that the process exits after the signal, optionally checking a close-hook marker;
  • a non-zero exit on failure, and no server process left behind;
  • support for the current runtime and .output layout without hard-coding Nitro internals.

What exists today:

  • nuxt preview starts the server but makes no assertions.
  • @nuxt/test-utils is excellent for tests that call the server, but it does not own the built process lifecycle or shutdown assertions.
  • Nitro close hooks are usually tested manually or with a custom script.

This could be a module, but a CLI command is the right home because it must know the output entry, environment loading and signal semantics. Happy to contribute the command or a shared helper. Our script is Bun-specific today; cross-platform signal handling is the main design work.

Additional information
  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?
Lingua principale
TypeScript
Stelle
402
Fork
125
Merge medio
2g 9h
PR unite (30g)
37

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nuxt/cli

Tutte le issue di nuxt/cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.