Skip to content

Instantly share code, notes, and snippets.

@scott-ho
Created September 3, 2019 09:51
Show Gist options
  • Save scott-ho/f1cff57c959f49987b0754c0b4520610 to your computer and use it in GitHub Desktop.
Save scott-ho/f1cff57c959f49987b0754c0b4520610 to your computer and use it in GitHub Desktop.
Nest Typeorm Destroy Problem
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'],
};
[
{
"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"
}
}
]
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