@@ -141,10 +141,7 @@ describe('lib/cloud/api', () => {
141
141
142
142
context ( '.rp' , ( ) => {
143
143
beforeEach ( ( ) => {
144
- // Because @packages /network is a bundled ES6 class with https://github.com/cypress-io/cypress/pull/32633
145
- // we can no longer mock the addRequest method on the agent singleton instance directly
146
- // Until we are able to convert this test to Vitest/TypeScript, we need to spy on the prototype
147
- sinon . spy ( CombinedAgent . prototype , 'addRequest' )
144
+ sinon . spy ( agent , 'addRequest' )
148
145
149
146
return nock . enableNetConnect ( )
150
147
} ) // nock will prevent requests from reaching the agent
@@ -155,9 +152,8 @@ describe('lib/cloud/api', () => {
155
152
return api . ping ( )
156
153
. thenThrow ( )
157
154
. catch ( ( ) => {
158
- expect ( CombinedAgent . prototype . addRequest ) . to . be . calledOnce
159
-
160
- expect ( CombinedAgent . prototype . addRequest ) . to . be . calledWithMatch ( sinon . match . any , {
155
+ expect ( agent . addRequest ) . to . be . calledOnce
156
+ expect ( agent . addRequest ) . to . be . calledWithMatch ( sinon . match . any , {
161
157
href : 'http://localhost:1234/ping' ,
162
158
} )
163
159
} )
@@ -169,9 +165,9 @@ describe('lib/cloud/api', () => {
169
165
return api . ping ( )
170
166
. thenThrow ( )
171
167
. catch ( ( ) => {
172
- expect ( CombinedAgent . prototype . addRequest ) . to . be . calledOnce
168
+ expect ( agent . addRequest ) . to . be . calledOnce
173
169
174
- expect ( CombinedAgent . prototype . addRequest ) . to . be . calledWithMatch ( sinon . match . any , {
170
+ expect ( agent . addRequest ) . to . be . calledWithMatch ( sinon . match . any , {
175
171
rejectUnauthorized : true ,
176
172
} )
177
173
} )
@@ -189,9 +185,9 @@ describe('lib/cloud/api', () => {
189
185
return api . ping ( )
190
186
. thenThrow ( )
191
187
. catch ( ( ) => {
192
- expect ( CombinedAgent . prototype . addRequest ) . to . be . calledOnce
188
+ expect ( agent . addRequest ) . to . be . calledOnce
193
189
194
- expect ( CombinedAgent . prototype . addRequest ) . to . be . calledWithMatch ( sinon . match . any , {
190
+ expect ( agent . addRequest ) . to . be . calledWithMatch ( sinon . match . any , {
195
191
href : 'http://localhost:1234/ping' ,
196
192
} )
197
193
} )
0 commit comments