MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / isAngularFixture

Function isAngularFixture

packages/angular/patch-vitest.ts:125–175  ·  view source on GitHub ↗

* Check if is an Angular fixture * * @param val Angular fixture * @returns boolean who check if is an angular fixture

(val: any)

Source from the content-addressed store, hash-verified

123 * @returns boolean who check if is an angular fixture
124 */
125function isAngularFixture(val: any): boolean {
126 if (typeof val !== 'object') {
127 return false;
128 }
129
130 if (val['componentRef'] || val['componentInstance']) {
131 return true;
132 }
133
134 if (val['componentType']) {
135 return true;
136 }
137
138 // * Angular fixture keys in Fixture component Object
139 const fixtureKeys = [
140 'componentRef',
141 'ngZone',
142 'effectRunner',
143 '_autoDetect',
144 '_isStable',
145 '_isDestroyed',
146 '_resolve',
147 '_promise',
148 '_onUnstableSubscription',
149 '_onStableSubscription',
150 '_onMicrotaskEmptySubscription',
151 '_onErrorSubscription',
152 'changeDetectorRef',
153 'elementRef',
154 'debugElement',
155 'componentInstance',
156 'nativeElement',
157 ];
158
159 // * Angular fixture keys in Fixture componentRef Object
160 const fixtureComponentRefKeys = [
161 'location',
162 '_rootLView',
163 '_tNode',
164 'previousInputValues',
165 'instance',
166 'changeDetectorRef',
167 'hostView',
168 'componentType',
169 ];
170
171 return (
172 JSON.stringify(Object.keys(val)) === JSON.stringify(fixtureKeys) ||
173 JSON.stringify(Object.keys(val)) === JSON.stringify(fixtureComponentRefKeys)
174 );
175}
176
177/**
178 * Serialize Angular fixture for Vitest

Callers 1

testFunction · 0.85

Calls 1

keysMethod · 0.65

Tested by 1

testFunction · 0.68