Jest has detected the following 1 open handle potentially keeping Jest from exiting: TCPSERVERWRAP

I still haven’t found a perfect solution, but for the moment I went for this workaround : jest –config ./test/jest-e2e.json –forceExit The –forceExit option kill the openHandles somehow and unlock everything. Yet, I’m still looking for the “proper way” of handling that issue.

Nestjs Dependency Injection and DDD / Clean Architecture

Export a symbol or a string along with your interface with the same name export interface IService { get(): Promise<string> } export const IService = Symbol(“IService”); Now you can basically use IService as both the interface and the dependency token import { IService } from ‘../interfaces/service’; @Injectable() export class ServiceImplementation implements IService { // Used … Read more

Password confirmation in TypeScript with `class-validator`

Finally I managed to solve the password matching problem thanks to the suggestion of @ChristopheGeers in the comments of my question: @piero: It’s not supported yet as mentioned. But here’s an example decorator (@IsLongerThan): LINK …. it checks if a property is longer than another one. So it’s possible to compare one property against another. … Read more

NestJS – Test suite failed to run Cannot find module ‘src/article/article.entity’ from ‘comment/comment.entity.ts’

You can tell Jest how to resolve module paths by configuring the moduleNameMapper option, which is useful if you’re using packages like module-alias or if you’re using absolute paths. Add these lines to your Jest configuration: { // … “jest”: { // … “moduleNameMapper”: { “^src/(.*)$”: “<rootDir>/$1” } } } Now modules that start with … Read more

How can I create columns with type Date and type DateTime in nestjs with typeORM?

You can see the docs here that explains the @Column decorator. In @Column there is an option called type -> here is where you specify which type of date you want to store for that specific column. More on column types here. For example (using PostgreSQL): @Column({ type: ‘date’ }) date_only: string; @Column({ type: ‘timestamptz’ … Read more

Why do we need DTOs and interfaces both in NestJS

According to the Nestjs docs: But first (if you use TypeScript), we need to determine the DTO (Data Transfer Object) schema. A DTO is an object that defines how the data will be sent over the network. We could determine the DTO schema by using TypeScript interfaces, or by simple classes. Interestingly, we recommend using … Read more

How to print stack trace with reference to typescript source in Nest.js

For visibility purposes: adding the source-map-support NPM package allows for tracing typescript files in the stack trace. It can be added on the command line with node -r source-map-support/register fileToRun.js or programatically with import * as sourceMapSupport from ‘source-map-support’; sourceMapSupport.install(); OR import { install } from ‘source-map-support’; install(); OR with ES6 modules import ‘source-map-support/register’;

Mongoose Subdocuments in Nest.js

I dug into the source code and learned how Schema class is converted by the SchemaFactory.createForClass method. Well so how it works? 1. Take a look at this example below: @Schema() export class Cat extends Document { @Prop() name: string; } export const catSchema = SchemaFactory.createForClass(Cat); Basically, when you do SchemaFactory.createForClass(Cat) Nest will convert the … Read more

GraphQLError: Query root type must be provided

All servers running with GraphQL must have at least one @Query() to be considered a valid GraphQL server. Without it, the apollo-server package will throw an exception and the server will fail to start. This can be as simple as @Resolver() export class FooResolver { @Query(() => String) sayHello(): string { return ‘Hello World!’; } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)