11import * as assert from 'assert' ;
22import * as sinon from 'sinon' ;
3- import * as fs from 'fs ' ;
4- import { agent as supertest } from 'supertest ' ;
3+ import * as request from 'supertest ' ;
4+ import proxyquire from 'proxyquire ' ;
55import 'should' ;
66import 'should-http' ;
77import 'should-sinon' ;
@@ -10,29 +10,28 @@ import { BitGo } from 'bitgo';
1010import { PostSignerMacaroon } from '../../../src/typedRoutes/api/v2/signerMacaroon' ;
1111import { LndSignerClient } from '../../../src/lightning/lndSignerClient' ;
1212
13+ proxyquire . noPreserveCache ( ) ;
14+
1315describe ( 'Signer Macaroon Typed Routes Tests' , function ( ) {
14- let agent : ReturnType < typeof supertest > ;
15- const tempFilePath = '/tmp/test-lightning-signer.json' ;
16+ let agent : request . SuperAgentTest ;
1617
1718 before ( function ( ) {
18- // Create a temporary JSON file for lightning signer config
19- fs . writeFileSync ( tempFilePath , JSON . stringify ( { } ) ) ;
20-
21- const { app } = require ( '../../../src/expressApp' ) ;
22- // Configure app with lightning signer enabled
23- const config = {
24- ...require ( '../../../src/config' ) . DefaultConfig ,
25- lightningSignerFileSystemPath : tempFilePath ,
19+ const validLightningSignerConfigJSON = '{}' ;
20+ const { app } = proxyquire ( '../../../src/expressApp' , {
21+ fs : {
22+ readFileSync : ( ) => validLightningSignerConfigJSON ,
23+ } ,
24+ } ) ;
25+
26+ const args : any = {
27+ debug : false ,
28+ env : 'test' ,
29+ logfile : '/dev/null' ,
30+ lightningSignerFileSystemPath : '/mock/path/lightning-signer.json' ,
2631 } ;
27- const testApp = app ( config ) ;
28- agent = supertest ( testApp ) ;
29- } ) ;
3032
31- after ( function ( ) {
32- // Clean up the temporary file
33- if ( fs . existsSync ( tempFilePath ) ) {
34- fs . unlinkSync ( tempFilePath ) ;
35- }
33+ const testApp = app ( args ) ;
34+ agent = request . agent ( testApp ) ;
3635 } ) ;
3736
3837 afterEach ( function ( ) {
0 commit comments