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

Open
#1,661 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
bun, node.js, typescript
Domain
cli, testing

Research direction

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.

Written by the indexing model from the issue text.

Description

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?
Dominant language
TypeScript
Stars
402
Forks
125
Avg merge
2d 9h
Merged PRs (30d)
37

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nuxt/cli

All issues in nuxt/cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.