MCPcopy Create free account
hub / github.com/angular/angular / withModule

Function withModule

packages/core/testing/src/test_bed.ts:1099–1114  ·  view source on GitHub ↗
(
  moduleDef: TestModuleMetadata,
  fn?: Function | null,
)

Source from the content-addressed store, hash-verified

1097export function withModule(moduleDef: TestModuleMetadata): InjectSetupWrapper;
1098export function withModule(moduleDef: TestModuleMetadata, fn: Function): () => any;
1099export function withModule(
1100 moduleDef: TestModuleMetadata,
1101 fn?: Function | null,
1102): (() => any) | InjectSetupWrapper {
1103 if (fn) {
1104 // Not using an arrow function to preserve context passed from call site
1105 return function (this: unknown) {
1106 const testBed = TestBedImpl.INSTANCE;
1107 if (moduleDef) {
1108 testBed.configureTestingModule(moduleDef);
1109 }
1110 return fn.apply(this);
1111 };
1112 }
1113 return new InjectSetupWrapper(() => moduleDef);
1114}
1115
1116/** Host component used when creating directives during tests. */
1117class DirectiveTestHost {

Calls 2

applyMethod · 0.65

Tested by

no test coverage detected