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

Method tearDownTestingModule

packages/core/testing/src/test_bed.ts:975–997  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

973 }
974
975 tearDownTestingModule() {
976 // If the module ref has already been destroyed, we won't be able to get a test renderer.
977 if (this._testModuleRef === null) {
978 return;
979 }
980 // Resolve the renderer ahead of time, because we want to remove the root elements as the very
981 // last step, but the injector will be destroyed as a part of the module ref destruction.
982 const testRenderer = this.inject(TestComponentRenderer);
983 try {
984 this._testModuleRef.destroy();
985 } catch (e) {
986 if (this.shouldRethrowTeardownErrors()) {
987 throw e;
988 } else {
989 console.error('Error during cleanup of a testing module', {
990 component: this._testModuleRef.instance,
991 stacktrace: e,
992 });
993 }
994 } finally {
995 testRenderer.removeAllRootElements?.();
996 }
997 }
998
999 /**
1000 * Execute any pending effects by executing any pending work required to synchronize model to the UI.

Callers 1

resetTestingModuleMethod · 0.95

Calls 5

injectMethod · 0.95
destroyMethod · 0.65
errorMethod · 0.65
removeAllRootElementsMethod · 0.45

Tested by

no test coverage detected