Open topchyalexey opened 9 months ago
Fixed by adding
**import { initializeTransactionalContext } from 'typeorm-transactional';**
import { AppModule } from '../src/app.module';
describe('AuthController (e2e)', () => {
let app: INestApplication;
let accessToken: string;
beforeAll(async () => {
**initializeTransactionalContext();**
const moduleFixture = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});
but then I get next error
[Nest] 65272 - 12/12/2023, 12:37:56 PM ERROR [ExceptionsHandler] You need to use @UseDto on class (UserEntity) be able to call toDto function
Error: You need to use @UseDto on class (UserEntity) be able to call toDto function
at UserEntity.toDto (/Users/aleksey.topchy/IdeaProjects/philit/medical/aip-back/src/common/abstract.entity.ts:24:19)
at AuthController.userRegister (/Users/aleksey.topchy/IdeaProjects/philit/medical/aip-back/src/modules/auth/auth.controller.ts:33:28)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
console.log
query: SELECT "UserEntity"."id" AS "UserEntity_id", "UserEntity"."created_at" AS "UserEntity_created_at", "UserEntity"."updated_at" AS "UserEntity_updated_at", "UserEntity"."first_name" AS "UserEntity_first_name", "UserEntity"."last_name" AS "UserEntity_last_name", "UserEntity"."role" AS "UserEntity_role", "UserEntity"."email" AS "UserEntity_email", "UserEntity"."password" AS "UserEntity_password", "UserEntity"."phone" AS "UserEntity_phone", "UserEntity"."avatar" AS "UserEntity_avatar", (SELECT CONCAT("UserEntity".first_name, ' ', "UserEntity".last_name)) AS "UserEntity_full_name" FROM "users" "UserEntity" WHERE ("UserEntity"."email" = $1) LIMIT 1 -- PARAMETERS: ["john@smith.com"]
at Function.logInfo (../src/platform/PlatformTools.ts:232:17)
Fixed it by this issue workaround https://github.com/NarHakobyan/awesome-nest-boilerplate/issues/332
on node 16 environment