* Trigger a change detection cycle for the component.
(checkNoChanges = true)
| 130 | * Trigger a change detection cycle for the component. |
| 131 | */ |
| 132 | detectChanges(checkNoChanges = true): void { |
| 133 | const originalCheckNoChanges = (this.changeDetectorRef as InternalViewRef<unknown>) |
| 134 | .checkNoChanges; |
| 135 | try { |
| 136 | if (!checkNoChanges) { |
| 137 | (this.changeDetectorRef as InternalViewRef<unknown>).checkNoChanges = () => {}; |
| 138 | } |
| 139 | |
| 140 | if (this.zonelessEnabled) { |
| 141 | try { |
| 142 | this._testAppRef.includeAllTestViews = true; |
| 143 | this._appRef.tick(); |
| 144 | } finally { |
| 145 | this._testAppRef.includeAllTestViews = false; |
| 146 | } |
| 147 | } else { |
| 148 | // Run the change detection inside the NgZone so that any async tasks as part of the change |
| 149 | // detection are captured by the zone and can be waited for in isStable. |
| 150 | this._ngZone.run(() => { |
| 151 | // Flush root effects before `detectChanges()`, to emulate the sequencing of `tick()`. |
| 152 | this.rootEffectScheduler.flush(); |
| 153 | this.changeDetectorRef.detectChanges(); |
| 154 | this.checkNoChanges(); |
| 155 | }); |
| 156 | } |
| 157 | } finally { |
| 158 | (this.changeDetectorRef as InternalViewRef<unknown>).checkNoChanges = originalCheckNoChanges; |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * Do a change detection run to make sure there were no changes. |
no test coverage detected