Skip to content

Commit e25b5eb

Browse files
authored
feat: allow overriding global teardown options (#502)
1 parent 39dec2a commit e25b5eb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

projects/spectator/src/lib/base/initial-module.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ export function initialModule(options: Required<BaseSpectatorOptions>): ModuleMe
2727
return {
2828
declarations: [...globals.declarations, ...options.declarations, ...options.entryComponents],
2929
imports: [...(options.disableAnimations ? [NoopAnimationsModule] : []), ...globals.imports, ...options.imports],
30-
providers: [...globals.providers, ...options.providers, ...options.mocks.map(type => options.mockProvider(type))],
30+
providers: [...globals.providers, ...options.providers, ...options.mocks.map((type) => options.mockProvider(type))],
3131
entryComponents: [...options.entryComponents],
32-
teardown: {...options.teardown}
32+
teardown:
33+
// Caretaker note: we don't want to merge the `globals.teardown` and `options.teardown`, since `options.teardown`
34+
// is always defined. If the user calls `defineGlobalsInjections({ teardown: { ... } })` and we merge it with
35+
// `options.teardown`, then `options.teardown` will always override global options.
36+
{ ...(globals.teardown || options.teardown) },
3337
};
3438
}

0 commit comments

Comments
 (0)