DEV Community

Discussion on: Tests with Jest and TypeORM

Collapse
 
samrith profile image
Samrith Shankar

Here you go:

const entityDeletionPromises = entities.map((entity) => async() => {
  const repository = connection.getRepository(entity.name);
  await repository.query(`DELETE FROM ${entity.tableName}`);
});
await Promise.all(entityDeletionPromises);
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
jackbilestech profile image
jack-biles-technology • Edited

I'm currently using typeorm 0.2.31 and they allow for repo.clear() to truncate / drop the table