Привет, у меня есть
import { Injectable } from '@nestjs/common';
import { Knex } from 'knex';
import { InjectConnection } from 'nest-knexjs';
import type { UserEntity } from './entities/user.entity';
@Injectable()
export class UsersService {
constructor(@InjectConnection() private readonly knex: Knex) {}
async findOne(email: UserEntity['email']): Promise<UserEntity | undefined> {
return await this.knex
.select()
.from('users')
.where({ email: email })
.first();
}
}
как написать тест в nestJs
вариант в виде
import { Test, TestingModule } from '@nestjs/testing';
import { UsersService } from './users.service';
describe('UsersService', () => {
let service: UsersService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [UsersService],
}).compile();
service = module.get<UsersService>(UsersService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
вылетает в
UsersService › should be defined
Nest can't resolve dependencies of the UsersService (?). Please make sure that the argument default at index [0] is available in the RootTestModule context.