Closed Javarome closed 1 year ago
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
π Bug Report
Issue Description
I have a working NestJS server that performs some TypeORM
repository.insert()
command. However when running the same operation from a Jest test (using@nestjs/testing
'sTest.createTestingModule(...)
, the infamousRight-hand side of 'instanceof' is not an object
appears.Looking in more details, it appears that this is due to some dynamic loading occurring in TypeORM's
QueryBuilder
:That line succeeds when running the NestJS server but fails when running the Jest test. More specifically:
require("./InsertQueryBuilder")
returns an ES module with aInsertQueryBuilder
in it. When setting a breakpoint here, strangely the debugged file appears located atsrc/query-builder/QueryBuilder.ts
(which is non-existent, and should rather benode_modules/typeorm/query-builder/QueryBuilder.js
), but this succeeds.require("./InsertQueryBuilder")
return an empty object, and soInsertQueryBuilder
isundefined
which not an object indeed. The debugged file is as expectednode_modules/typeorm/query-builder/QueryBuilder.js
, but this fails.Expected Behavior
Same behavior when launching the server and the test.
Actual Behavior
Exception is raised:
Steps to Reproduce
TypeOrmModule.forRoot(options)
andTypeOrmModule.forFeature([MyEntity])
@InjectRepository(StoredPrediction) repository
constructor parameter, then attempts torepository.insert(myEntity)
My Environment
My Jest configuration is as follows:
as my Typescript sources are under a src directory under the project root. Those path issues are also be related to my tsconfig.json, which contains:
Additional Context
My directory structure is: