I encountered the following error :
Nest is unable to resolve dependencies of the ParametrageRepository (?). Please ensure that the argument DataSource at index [0] is available in the TypeOrmModule context.
This is my test code :
describe("ParametrageController (e2e)", () => {
let parametrage: INestApplication;
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [ParametrageModule],
}).compile();
parametrage = moduleFixture.createNestApplication();
await parametrage.init();
});
it("/ (POST)", () =>
request(parametrage.getHttpServer())
.post("/parametrage")
.send({
libelle: "GROUPE_TYPE",
liste: ["TEAM", "SERVICE", "ORGANISATION"],
})
.expect(201));
});
This is my module code:
@Module({
imports: [TypeOrmModule.forFeature([Parametrage])],
exports: [TypeOrmModule],
controllers: [ParametrageController],
providers: [ParametrageService, ParametrageRepository, ParametrageActions, Logger],
})
export class ParametrageModule {}
I am unsure why I am facing this error even though I followed the Nestjs documentation. It's possible that I missed a crucial step or overlooked something while setting up my providers with parameters in their constructors :
This is my ParametrageRepository provider :
@Injectable()
export class ParametrageRepository
extends RepositoryStarter<Parametrage, IParametrageListFilter>
implements IParametrageRepository
{
constructor(@InjectDataSource() datasource: DataSource) {
super(datasource.getRepository(Parametrage));
}
I attempted to introduce provider injection :
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [ParametrageModule],
** providers: [
{ provide: ParametrageActions, useValue: ParametrageActions },
{ provide: ParametrageRepository, useValue: ParametrageRepository },
{ provide: Logger, useValue: Logger ,
],**
}).compile();
However, the error persists and remains unsolved
Appreciate any help in advance