You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there an existing issue that is already proposing this?
I have searched the existing issues
Is your feature request related to a problem? Please describe it
Here is a minimum reproducible example attempting to run Cypress e2e tests against a nestjs api which uses a dto annotated with an @ApiProperty() decorator from @nestjs/swagger : https://github.com/larriereguichet/nestjs-cypress
Attempting to run the tests with npm run test:cypress ends up with the following error :
Error: Webpack Compilation Error
./node_modules/@nestjs/core/nest-application.js
Module not found: Error: Can't resolve '@nestjs/microservices' in '~/workspace/nestjs-cypress/node_modules/@nestjs/core'
resolve '@nestjs/microservices' in '~/workspace/nestjs-cypress/node_modules/@nestjs/core'
# [...]
@ ./node_modules/@nestjs/core/nest-application.js 122:120-152
@ ./node_modules/@nestjs/core/index.js
@ ./node_modules/@nestjs/swagger/dist/swagger-explorer.js
@ ./node_modules/@nestjs/swagger/dist/swagger-scanner.js
@ ./node_modules/@nestjs/swagger/dist/swagger-module.js
@ ./node_modules/@nestjs/swagger/dist/index.js
@ ./node_modules/@nestjs/swagger/index.js
@ ./src/dto/cat.dto.ts
@ ./cypress/e2e/dto.cy.ts
at handle (~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/@packages/server/node_modules/@cypress/webpack-preprocessor/dist/index.js:212:23)
at finalCallback (~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:257:39)
at ~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:306:14
at AsyncSeriesHook.eval [as callAsync] (eval at create (~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/tapable/lib/Hook.js:154:20)
at ~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:304:22
at Compiler.emitRecords (~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:499:39)
at ~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:298:10
at ~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:485:14
at AsyncSeriesHook.eval [as callAsync] (eval at create (~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/tapable/lib/Hook.js:154:20)
at ~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:482:27
at ~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/neo-async/async.js:2818:7
at done (~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/neo-async/async.js:3522:9)
at AsyncSeriesHook.eval [as callAsync] (eval at create (~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/tapable/lib/Hook.js:154:20)
at ~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/webpack/lib/Compiler.js:464:33
at ~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/graceful-fs.js:143:16
at ~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/graceful-fs.js:143:16
at ~/.cache/Cypress/12.10.0/Cypress/resources/app/node_modules/@packages/server/node_modules/graceful-fs/graceful-fs.js:61:14
at FSReqCallback.oncomplete (node:fs:197:23)
import{CatDto}from'../../src/dto/cat.dto';describe('dtos (cypress e2e)',()=>{it('can instantiate a dto annotated with an ApiProperty decorator',()=>{newCatDto();});});
Note : This was originally an attempt of using Cypress against a nestjs api in an nx repository using @nrwl/cypress and if a solution is found it could also be used in such context.
The solution probably lie in a custom webpack configuration but I fail at finding the how and where it should be done.
Describe the solution you'd like
When creating a nestjs app, there could be the choice of the e2e testing library :
supertest
cypress
(or) There could be a documentation entry illustrating a way to run cypress tests when an annotated dto is involved.
I don't think we should prompt the user to select the testing lib for e2e because supertest can be easily changed by any other as there isn't much code to remove
There are no plans to implement it in the foreseeable future.
If you think your request could live outside Nest's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
Here is a minimum reproducible example attempting to run Cypress e2e tests against a nestjs api which uses a
dto
annotated with an@ApiProperty()
decorator from@nestjs/swagger
:https://github.com/larriereguichet/nestjs-cypress
Attempting to run the tests with
npm run test:cypress
ends up with the following error :src/dto/cat.dto.ts
:cypress/e2e/dto.cy.ts
:The solution probably lie in a custom webpack configuration but I fail at finding the how and where it should be done.
Describe the solution you'd like
nestjs
app, there could be the choice of the e2e testing library :cypress
tests when an annotated dto is involved.Teachability, documentation, adoption, migration strategy
What is the motivation / use case for changing the behavior?
Cypress is (one of) the most popular e2e testing library and there could be a solution to use it against a documented nestjs Rest API.
The text was updated successfully, but these errors were encountered: