@@ -3,14 +3,30 @@ import Replicate, { ApiError, Prediction } from 'replicate';
3
3
import nock from 'nock' ;
4
4
import fetch from 'cross-fetch' ;
5
5
6
- describe ( 'Replicate client' , ( ) => {
7
- let client : Replicate ;
6
+ let client : Replicate ;
7
+ const BASE_URL = 'https://api.replicate.com/v1' ;
8
+
9
+ nock . disableNetConnect ( ) ;
8
10
9
- const BASE_URL = 'https://api.replicate.com/v1' ;
11
+ describe ( 'Replicate client' , ( ) => {
12
+ let unmatched : Object [ ] = [ ] ;
13
+ const handleNoMatch = ( req : unknown , options : any , body : string ) =>
14
+ unmatched . push ( { req, options, body } ) ;
10
15
11
16
beforeEach ( ( ) => {
12
17
client = new Replicate ( { auth : 'test-token' } ) ;
13
18
client . fetch = fetch ;
19
+
20
+ unmatched = [ ] ;
21
+ nock . emitter . on ( "no match" , handleNoMatch ) ;
22
+ } ) ;
23
+
24
+ afterEach ( ( ) => {
25
+ nock . emitter . off ( "no match" , handleNoMatch ) ;
26
+ expect ( unmatched ) . toStrictEqual ( [ ] ) ;
27
+
28
+ nock . abortPendingRequests ( ) ;
29
+ nock . cleanAll ( ) ;
14
30
} ) ;
15
31
16
32
describe ( 'constructor' , ( ) => {
@@ -188,7 +204,7 @@ describe('Replicate client', () => {
188
204
} , { "Content-Type" : "application/json" } )
189
205
190
206
try {
191
- expect . assertions ( 2 ) ;
207
+ expect . hasAssertions ( ) ;
192
208
193
209
await client . predictions . create ( {
194
210
version : '5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa' ,
0 commit comments