@@ -12,6 +12,7 @@ const encryption = require('../../../../lib/cloud/encryption')
12
12
const {
13
13
agent,
14
14
} = require ( '@packages/network' )
15
+ const { CombinedAgent } = require ( '@packages/network/lib/agent' )
15
16
const pkg = require ( '@packages/root' )
16
17
const api = require ( '../../../../lib/cloud/api' ) . default
17
18
const cache = require ( '../../../../lib/cache' ) . cache
@@ -140,7 +141,10 @@ describe('lib/cloud/api', () => {
140
141
141
142
context ( '.rp' , ( ) => {
142
143
beforeEach ( ( ) => {
143
- sinon . spy ( agent , 'addRequest' )
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
148
145
149
return nock . enableNetConnect ( )
146
150
} ) // nock will prevent requests from reaching the agent
@@ -151,9 +155,9 @@ describe('lib/cloud/api', () => {
151
155
return api . ping ( )
152
156
. thenThrow ( )
153
157
. catch ( ( ) => {
154
- expect ( agent . addRequest ) . to . be . calledOnce
158
+ expect ( CombinedAgent . prototype . addRequest ) . to . be . calledOnce
155
159
156
- expect ( agent . addRequest ) . to . be . calledWithMatch ( sinon . match . any , {
160
+ expect ( CombinedAgent . prototype . addRequest ) . to . be . calledWithMatch ( sinon . match . any , {
157
161
href : 'http://localhost:1234/ping' ,
158
162
} )
159
163
} )
@@ -165,9 +169,9 @@ describe('lib/cloud/api', () => {
165
169
return api . ping ( )
166
170
. thenThrow ( )
167
171
. catch ( ( ) => {
168
- expect ( agent . addRequest ) . to . be . calledOnce
172
+ expect ( CombinedAgent . prototype . addRequest ) . to . be . calledOnce
169
173
170
- expect ( agent . addRequest ) . to . be . calledWithMatch ( sinon . match . any , {
174
+ expect ( CombinedAgent . prototype . addRequest ) . to . be . calledWithMatch ( sinon . match . any , {
171
175
rejectUnauthorized : true ,
172
176
} )
173
177
} )
@@ -185,9 +189,9 @@ describe('lib/cloud/api', () => {
185
189
return api . ping ( )
186
190
. thenThrow ( )
187
191
. catch ( ( ) => {
188
- expect ( agent . addRequest ) . to . be . calledOnce
192
+ expect ( CombinedAgent . prototype . addRequest ) . to . be . calledOnce
189
193
190
- expect ( agent . addRequest ) . to . be . calledWithMatch ( sinon . match . any , {
194
+ expect ( CombinedAgent . prototype . addRequest ) . to . be . calledWithMatch ( sinon . match . any , {
191
195
href : 'http://localhost:1234/ping' ,
192
196
} )
193
197
} )
0 commit comments