Skip to content

Instantly share code, notes, and snippets.

@Goldziher
Created August 1, 2021 06:33
Show Gist options
  • Save Goldziher/16b0462e603553414ea1ea3ccbc17e1a to your computer and use it in GitHub Desktop.
Save Goldziher/16b0462e603553414ea1ea3ccbc17e1a to your computer and use it in GitHub Desktop.
Example test
import { User } from '@backend/db/entities/User';
import { getConnection } from 'typeorm';
describe('Some Test', () => {
const connection = getConnection('default');
let user: User;
beforeEach(async () => {
const userRepository = connection.getRepository(User);
const user = userRepository.create({
firstName: 'John',
lastName: 'Smith',
email: 'js@test.com',
isActive: true,
profile: {
location: 'Berlin Metropolitan Area',
employer: 'Yo-Yo Inc.',
profession: 'Chef',
phoneNumber: '+491234567890',
imageUrl: 'https://www.example.com/user123',
birthDate: new Date('01.01.2000'),
},
});
await userRepository.save(user);
});
// ...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment