Created
September 3, 2019 09:51
-
-
Save scott-ho/f1cff57c959f49987b0754c0b4520610 to your computer and use it in GitHub Desktop.
Nest Typeorm Destroy Problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
globals: { | |
'ts-jest': { | |
diagnostics: { | |
warnOnly: true, | |
}, | |
}, | |
}, | |
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'], | |
transform: { | |
'^.+\\.tsx?$': 'ts-jest', | |
}, | |
testRegex: '/e2e/.*\\.e2e-spec.(ts|tsx|js)$', | |
collectCoverageFrom: ['src/**/*.{js,jsx,tsx,ts}', '!**/node_modules/**', '!**/vendor/**'], | |
coverageReporters: ['json', 'lcov'], | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "development", | |
"type": "mysql", | |
"host": "localhost", | |
"port": 3306, | |
"username": "nest", | |
"password": "nest", | |
"database": "dev", | |
"entities": ["src/**/**.entity.ts"], | |
"synchronize": true, | |
"migrations": ["migrations/*.ts"], | |
"cli": { | |
"migrationsDir": "migrations" | |
} | |
}, | |
{ | |
"name": "test", | |
"type": "mysql", | |
"host": "localhost", | |
"port": 3306, | |
"username": "testing", | |
"password": "", | |
"database": "test", | |
"dropSchema": true, | |
"logging": false, | |
"synchronize": true, | |
"multipleStatements": true, | |
"entities": ["src/**/**.entity.ts"], | |
"migrationsRun": false, | |
"migrations": ["migrations/*.ts", "migrations/tests/*.ts"], | |
"cli": { | |
"migrationsDir": "migrations" | |
} | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { INestApplication } from '@nestjs/common'; | |
import { Test } from '@nestjs/testing'; | |
import { TypeOrmModule } from '@nestjs/typeorm'; | |
import { getConnectionOptions } from 'typeorm'; | |
describe('Users', () => { | |
let app: INestApplication; | |
beforeAll(async () => { | |
const module = await Test.createTestingModule({ | |
imports: [ | |
TypeOrmModule.forRootAsync({ | |
useFactory: () => { | |
return getConnectionOptions('test'); | |
}, | |
})], | |
}) | |
.compile(); | |
app = module.createNestApplication(); | |
await app.init(); | |
}); | |
test(`/GET user by email`, () => { | |
return true | |
}); | |
afterAll(async () => { | |
try{ | |
await app.close(); | |
} | |
catch (e) { | |
console.error(e) | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment