nest icon indicating copy to clipboard operation
nest copied to clipboard

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

Open Alverrt opened this issue 1 year ago • 1 comments
trafficstars

Is there an existing issue for this?

  • [X] 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
  • [X] @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?

  • [X] macOS
  • [ ] Windows
  • [ ] Linux

Other

No response

Alverrt avatar May 03 '24 23:05 Alverrt