File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed
Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -82,9 +82,14 @@ afterEach(async () => {
8282 } ) ;
8383 activeIntervals . clear ( ) ;
8484
85- // Clear any nock interceptors
86- if ( typeof require ( 'nock' ) !== 'undefined' ) {
87- require ( 'nock' ) . cleanAll ( ) ;
85+ // Clear any nock interceptors (only if nock has already been loaded)
86+ try {
87+ const nock = require . resolve ( 'nock' ) ;
88+ if ( require . cache [ nock ] ) {
89+ require ( 'nock' ) . cleanAll ( ) ;
90+ }
91+ } catch ( e ) {
92+ // nock not installed, skip
8893 }
8994} ) ;
9095
Original file line number Diff line number Diff line change @@ -244,16 +244,14 @@ describe('NetbootXYZ WebApp', () => {
244244 nock . cleanAll ( ) ;
245245 nock ( 'https://api.github.com' )
246246 . get ( '/repos/netbootxyz/netboot.xyz/releases/latest' )
247- . replyWithError ( 'Network error' ) ;
247+ . reply ( 500 , { message : 'Internal Server Error' } ) ;
248248
249249 // The app should handle network failures gracefully
250250 const fetch = require ( 'node-fetch' ) ;
251251
252- try {
253- await fetch ( 'https://api.github.com/repos/netbootxyz/netboot.xyz/releases/latest' ) ;
254- } catch ( error ) {
255- expect ( error . message ) . toContain ( 'Network error' ) ;
256- }
252+ const response = await fetch ( 'https://api.github.com/repos/netbootxyz/netboot.xyz/releases/latest' ) ;
253+ expect ( response . ok ) . toBe ( false ) ;
254+ expect ( response . status ) . toBe ( 500 ) ;
257255 } ) ;
258256 } ) ;
259257
You can’t perform that action at this time.
0 commit comments