nestjs / docs.nestjs.com

The official documentation https://docs.nestjs.com 📕
MIT License
1.13k stars 1.62k forks source link

Something seems off when using vitest; perhaps it needs to be added to the documentation. #3021

Closed Alverrt closed 1 month ago

Alverrt commented 1 month ago

Is there an existing issue for this?

Current behavior

When I try to do e2e test of my AuthModule (with fastify adapter) via creating the test module with importing AppModule, I get nonsense Error: Nest can't resolve dependencies error. I did every solution exist in both github + stackoverflow but none of them worked.

Finally I found this thread in Discord.

When I installed the package and add to vite.config.ts as plugin, issue was resolved. I still have no idea why it worked but, I think it should be in docs as required package.

Minimum reproduction code

https://discord.com/channels/520622812742811698/1181664557693935677

Steps to reproduce

No response

Expected behavior

.

Package

Other package

vitest

NestJS version

10.0.0

Packages versions

{
"dependencies": {
    "@faker-js/faker": "8.4.1",
    "@fastify/static": "7.0.3",
    "@nestjs/common": "^10.0.0",
    "@nestjs/config": "3.2.2",
    "@nestjs/core": "^10.0.0",
    "@nestjs/jwt": "10.2.0",
    "@nestjs/platform-express": "^10.0.0",
    "@nestjs/platform-fastify": "10.3.7",
    "@nestjs/swagger": "7.3.1",
    "@types/pg": "8.11.5",
    "class-transformer": "0.5.1",
    "class-validator": "0.14.1",
    "dotenv": "16.4.5",
    "drizzle-orm": "0.30.9",
    "fastify": "4.26.2",
    "nestjs-pino": "4.0.0",
    "pg": "8.11.5",
    "pino-pretty": "11.0.0",
    "postgres": "3.4.4",
    "reflect-metadata": "^0.2.0",
    "rxjs": "^7.8.1",
    "vite-tsconfig-paths": "4.3.2",
    "zod": "3.22.4"
  },
  "devDependencies": {
    "@nestjs/cli": "^10.0.0",
    "@nestjs/schematics": "^10.0.0",
    "@nestjs/testing": "^10.3.7",
    "@swc/core": "1.4.12",
    "@types/express": "^4.17.17",
    "@types/jest": "^29.5.2",
    "@types/node": "^20.3.1",
    "@types/supertest": "^6.0.0",
    "@typescript-eslint/eslint-plugin": "^6.0.0",
    "@typescript-eslint/parser": "^6.0.0",
    "@vitest/coverage-v8": "1.4.0",
    "drizzle-kit": "0.20.17",
    "eslint": "^8.42.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-prettier": "^5.0.0",
    "prettier": "^3.0.0",
    "source-map-support": "^0.5.21",
    "supertest": "^6.3.3",
    "ts-jest": "^29.1.0",
    "ts-loader": "^9.4.3",
    "ts-node": "^10.9.1",
    "tsconfig-paths": "^4.2.0",
    "tsx": "4.7.3",
    "typescript": "^5.1.3",
    "unplugin-swc": "1.4.5",
    "vitest": "^1.4.0"
  },
}

Node.js version

18.17.0

In which operating systems have you tested?

Other

No response

micalevisk commented 1 month ago

feel free to update the docs site at https://github.com/nestjs/docs.nestjs.com

I'm not sure if we should mention that, tho. Because it's a configuration on Vitest side that you may not face depending on how your test suite looks like (I guess)

Alverrt commented 1 month ago

My test suite was following classic nest instructions mentioned in docs. But my project was monorepo with pnpm workspaces. Still not sure if it is relative to this.

micalevisk commented 1 month ago

Can you share a minimum reproduction? So we can decide better if the docs should be updated or not

Alverrt commented 1 month ago

I will do it when I got off time.

kamilmysliwiec commented 1 month ago

It appears this isn't directly tied to NestJS. However, if you manage to create a repository that shows the issue originating from Nest, please share the link here, and I'll reopen the issue.