Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 of 15 tasks
Alverrt opened this issue May 3, 2024 · 5 comments
Closed
3 of 15 tasks

Comments

@Alverrt
Copy link

Alverrt commented May 3, 2024

Is there an existing issue for this?

  • I have searched the existing issues

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

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

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?

  • macOS
  • Windows
  • Linux

Other

No response

@micalevisk
Copy link
Member

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
Copy link
Author

Alverrt commented May 4, 2024

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
Copy link
Member

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

@kamilmysliwiec kamilmysliwiec transferred this issue from nestjs/nest May 5, 2024
@Alverrt
Copy link
Author

Alverrt commented May 7, 2024

I will do it when I got off time.

@kamilmysliwiec
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants