typeorm: 0.2.24 JEST tests suddenly throwing RepositoryNotFound, no changes to code
Issue type:
[ ] question [x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x
(or put your version here)
Steps to reproduce or a small repository showing the problem:
Not sure how exactly this started, I ran an dependency update to upgrade to TypeORM 0.2.24, and then suddenly my tests started failing, frustratingly just rolling back to .22 the error still happens, I believe some other dependency was updated with my yarn.lock, in general this issue has been problematic during development, but these tests had been working for 3 months without issue.
tsconfig.json
{
"compilerOptions": {
"lib": ["es5", "es6", "es2016", "es2017", "dom"],
"target": "ES2016",
"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,
"outDir": "./build",
"noImplicitAny": true,
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"*": ["node_modules/"],
"typings/*": ["src/typings/*"]
}
},
"include": ["src/**/*.ts"],
"exclude": ["src/test/**/*.spec.ts", "node_modules"]
}
jest.config.js
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
collectCoverage: true,
collectCoverageFrom: [
"./src/**/*.{ts,tsx,js,jsx}",
"!**/node_modules/**",
"!**/build/**",
"!./src/generated/**",
"!./src/migration/**"
],
testPathIgnorePatterns: [
"/node_modules/",
"/build/",
"/__utils",
"/__testData",
"/__queries"
],
globalSetup: "./src/jest.globalSetup.ts"
};
schema config:
export const schemaConfig = {
entities: ["build/entity/**/*.{js,ts}"],
migrations: ["build/migration/**/*.{js,ts}"],
subscribers: ["build/subscriber/**/*.{js,ts}"],
cli: {
entitiesDir: "src/entity",
migrationsDir: "src/migration",
subscribersDir: "src/subscriber"
}
};
RepositoryNotFoundError: No repository for "Card" was found. Looks like this entity is not registered in current "testConnection" connection?
You can see the full repo for these tests here: https://github.com/seandearnaley/brainstrike-typescript-starter/tree/master/server
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 4
- Comments: 20 (7 by maintainers)
Oh, I checked the PR and added some comment. I hope the PR to be accepted
I have solution @seandearnaley we can solve this problem with replacing code like this
Before
After
Object.getPrototypeOf(metadata.target) === Object.getPrototypeOf(target) will satisfy the problem requirement
please add new PR from this patch. it will work well
Yea - Iām looking at both. Because jest is involved here I have a feeling it could be similar but slightly different. š
thanks for working on that @YoonSeongKyeong