Skip to content

Instantly share code, notes, and snippets.

@Goldziher
Created August 1, 2021 06:37
Show Gist options
  • Save Goldziher/2a85e71ef3d75e21942bdbba70f8d17c to your computer and use it in GitHub Desktop.
Save Goldziher/2a85e71ef3d75e21942bdbba70f8d17c to your computer and use it in GitHub Desktop.
Re-written test example with batch
import { User } from '@backend/db/entities/User';
import { UserFactory } from '@backend/db/factories/User.factory';
import { getConnection } from 'typeorm';
describe('Some Other Test', () => {
const connection = getConnection('default');
let users: User[];
beforeEach(async () => {
const userRepository = connection.getRepository(User);
users = await userRepository.save(UserFactory.batchSync(10));
});
// ...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment