question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot inject the dependency at position #0 of

See original GitHub issue

I try create a test but this error persist. Maybe any incompatibility? ( On Insomnia all works fine.) When I use .get(‘/products’) always returns code 404 page not found.

at src/modules/session/Session.spec.ts:12:29 at step (src/modules/session/Session.spec.ts:33:23) at Object.next (src/modules/session/Session.spec.ts:14:53) at fulfilled (src/modules/session/Session.spec.ts:5:58)

console.log Error: Cannot inject the dependency at position #0 of “CreateSession” constructor. Reason: No repository for “User” was found. Looks like this entity is not registered in current “default” connection? at C:\Users\gleys\projects\jejconceito\node_modules\tsyringe\dist\cjs\dependency-container.js:209:23 at Array.map (<anonymous>) at InternalDependencyContainer.construct (C:\Users\gleys\projects\jejconceito\node_modules\tsyringe\dist\cjs\dependency-container.js:195:34) at InternalDependencyContainer.resolve (C:\Users\gleys\projects\jejconceito\node_modules\tsyringe\dist\cjs\dependency-container.js:81:25) at SessionController.<anonymous> (C:\Users\gleys\projects\jejconceito\src\modules\session\controller\SessionController.ts:9:44) at step (C:\Users\gleys\projects\jejconceito\src\modules\session\controller\SessionController.ts:33:23) at Object.next (C:\Users\gleys\projects\jejconceito\src\modules\session\controller\SessionController.ts:14:53) at C:\Users\gleys\projects\jejconceito\src\modules\session\controller\SessionController.ts:8:71 at new Promise (<anonymous>)

This is my code:

/* eslint-disable @typescript-eslint/camelcase */
import '@shared/infra/typeorm';
import request from 'supertest';
import app from '@shared/infra/http/app';

describe('Authentication', () => {
  it('should authenticate with valid credentials', async () => {
    const response = await request(app).post('/session').send({
      login: 'email',
      password: 'sss',
    });
    expect(response.status).toBe(200);
  });
});

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14

github_iconTop GitHub Comments

9reactions
JunioResendecommented, Mar 25, 2021

e necessario importar o container no primeiro arquivo da sua aplicacao

ex: import “./shared/container”

7reactions
gleysonabreucommented, Oct 29, 2020

The error happened because connection not initialized yet so create a async await connection and now works fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot inject the dependency "modelRepository" at position ...
Cannot inject the dependency "modelRepository" at position #0 of "GetModelService" constructor. Reason: Cannot read property 'name' of undefined.
Read more >
Cannot inject the dependency at position #0 of #666 - GitHub
The error happened because connection not initialized yet so create a async await connection and now works fine. 4
Read more >
[TypeScript] Try DI with TSyringe - DEV Community ‍ ‍
map((type, index) => { ^ Error: Cannot inject the dependency at position #0 of "Caller3" constructor. Reason: TypeInfo not known for "Object" .....
Read more >
tsyringe - npm.io
Error: Cannot inject the dependency at position #0 of "Foo" constructor. Reason: Attempted to construct an undefined constructor.
Read more >
Dependency Injection in TypeScript from scratch using TSyringe
Error: Cannot inject the dependency at position #0 of “Foo” constructor. Reason: Attempted to construct an undefined constructor.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found