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

Method destroyActiveFixtures

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

Source from the content-addressed store, hash-verified

889 }
890
891 private destroyActiveFixtures(): void {
892 let errorCount = 0;
893 this._activeFixtures.forEach((fixture) => {
894 try {
895 fixture.destroy();
896 } catch (e) {
897 errorCount++;
898
899 if (fixture instanceof ComponentFixture) {
900 console.error('Error during cleanup of component', {
901 component: fixture.componentInstance,
902 stacktrace: e,
903 });
904 } else if (fixture instanceof DirectiveFixture) {
905 console.error('Error during cleanup of directive', {
906 component: fixture.directiveInstance,
907 stacktrace: e,
908 });
909 } else {
910 console.error('Error during cleanup of fixture', e);
911 }
912 }
913 });
914 this._activeFixtures = [];
915
916 if (errorCount > 0 && this.shouldRethrowTeardownErrors()) {
917 throw Error(
918 `${errorCount} ${errorCount === 1 ? 'fixture' : 'fixtures'} ` +
919 `threw errors during cleanup`,
920 );
921 }
922 }
923
924 shouldRethrowTeardownErrors(): boolean {
925 const instanceOptions = this._instanceTeardownOptions;

Callers 1

resetTestingModuleMethod · 0.95

Calls 5

ErrorInterface · 0.85
destroyMethod · 0.65
errorMethod · 0.65
forEachMethod · 0.45

Tested by

no test coverage detected