DEV Community

Discussion on: Tests with Jest and TypeORM

Collapse
sadra profile image
Sadra Isapanah Amlashi • Edited on

Can you put your example here please?

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 on

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