nuxt / nuxt/test-utils

How to have coverage on e2e tests server-side

Open
#1,154 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pending triage
Dominant language
TypeScript
Stars
437
Forks
120
Avg merge
22h 52m
Merged PRs (30d)
23

Description

Describe the feature

How am I supposed to have coverage information when trying to test my API endpoints?

For what I can see, testing in nuxt is mainly frontend-accessed, but I would only like to test my API endpoints using Vitest, I tried using the setup function that we need to use when doing e2e tests, but it doesn't work for server-side coverage.

Here is the type of test I would like to do:

import { setup, $fetch } from "@nuxt/test-utils/e2e";
import { describe, it } from "vitest";

describe("[GET] /health", async () => {
  await setup({});

  it("should work", async () => {
    const { body} = await $fetch("/api/health");
    expect(body.msg).to.equal("ok");
  });
});
Additional information
  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?
Final checks

Contributor guide

Open the contributing guide

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.

Research direction

Start by reviewing the @nuxt/test-utils/e2e setup and the Vitest-based example in the issue, then compare how server-side API requests differ from frontend-accessed end-to-end tests. Determine how coverage is currently configured and what support is expected for /api/health requests. Done means a documented or tested way to collect server-side coverage for this use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxtjs, typescript
Domain
api, testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.