Skip to content

Commit 41ba27b

Browse files
authored
feat: add clear storage method (#133)
1 parent b1b69e1 commit 41ba27b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/mikro-orm.module.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ import { MikroOrmEntitiesStorage } from './mikro-orm.entities.storage';
1717
@Module({})
1818
export class MikroOrmModule {
1919

20+
/**
21+
* Clears the entity storage. This is useful for testing purposes, when you want to isolate the tests.
22+
* Keep in mind that this should be called when using a test runner that keeps the context alive between tests (like Vitest with threads disabled).
23+
*/
24+
static clearStorage(contextName?: string) {
25+
MikroOrmEntitiesStorage.clear(contextName);
26+
}
27+
2028
static forRoot(options?: MikroOrmModuleSyncOptions): DynamicModule {
2129
return {
2230
module: MikroOrmModule,

0 commit comments

Comments
 (0)