Why do errors occur when using '@nuxt/test-utils/e2e' for API testing?
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 437
- Forks
- 120
- Avg merge
- 22h 52m
- Merged PRs (30d)
- 23
Description
Summary (generated):
Here is a brief summary in English:
A developer is trying to set up end-to-end testing for server-side functionality in a Nuxt app using Nitro, but is encountering errors related to frontend routes despite setting server to true and browser to false. The error is apparently due to the absence of an index.vue file in the /pages directory, which is expected to contain application logic. The developer expects the setup to only run the server part and not be concerned with frontend parts.
Discussed in https://github.com/nuxt/nuxt/discussions/27820
Originally posted by manpreet-compro June 25, 2024
I am working on a Nuxt app and trying to set up end-to-end testing for server-side functionality related to API endpoints I have developed using Nitro. However, I encounter errors related to frontend routes despite my expectation to run only the server part without involving the frontend.
Test server setup code
await setup({
rootDir: fileURLToPath(new URL('../..', import.meta.url)),
server: true,
browser: false,
dev: true,
setupTimeout: 600 * 1000
});
I am setting server to true and browser to false. I am seeing the following error
I found out this error is related to frontend routes, particularly of absence of index.vue in my project under /pages which is expected application logic. I expected this setup to run only the server part and not be concerned with the frontend part.
Am I missing something? Any help will be appreciated
Following is vitest config file for reference
import { defineVitestConfig } from '@nuxt/test-utils/config';
export default defineVitestConfig({
test: {
reporters: 'verbose',
passWithNoTests: true
}
});
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the @nuxt/test-utils/e2e setup shown in the issue and the referenced Vitest configuration. Reproduce the server=true and browser=false case with and without /pages/index.vue, then compare the result with the related discussion. Done would be a documented explanation or an agreed change clarifying whether server-only API tests should require frontend routes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxtjs
- Domain
- api, backend, testing
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100