@@ -182,6 +182,20 @@ describe('ExportMarketplaceApps', () => {
182182 ( marketplaceAppHelper . getOrgUid as sinon . SinonStub ) . resolves ( 'test-org-uid' ) ;
183183 ( marketplaceAppHelper . getDeveloperHubUrl as sinon . SinonStub ) . resolves ( 'https://developer-api.contentstack.io' ) ;
184184
185+ // Stub setupPaths so org_uid and related state are set (getOrgUid stub may be bypassed when source imports via utils barrel in CI)
186+ const setupPathsStub = sinon . stub ( exportMarketplaceApps , 'setupPaths' ) . callsFake ( async ( ) => {
187+ exportMarketplaceApps . exportConfig . org_uid = 'test-org-uid' ;
188+ exportMarketplaceApps . developerHubBaseUrl = 'https://developer-api.contentstack.io' ;
189+ exportMarketplaceApps . query = { target_uids : 'test-stack-uid' } ;
190+ exportMarketplaceApps . appSdk = mockAppSdk ;
191+ exportMarketplaceApps . marketplaceAppPath = require ( 'node:path' ) . resolve (
192+ exportMarketplaceApps . exportConfig . exportDir ,
193+ exportMarketplaceApps . exportConfig . branchName || '' ,
194+ 'marketplace-apps' ,
195+ ) ;
196+ await FsUtility . prototype . makeDirectory ( exportMarketplaceApps . marketplaceAppPath ) ;
197+ } ) ;
198+
185199 // Mock exportApps and getAppManifestAndAppConfig to avoid complex setup
186200 const exportAppsStub = sinon . stub ( exportMarketplaceApps , 'exportApps' ) . resolves ( ) ;
187201 const getAppManifestAndAppConfigStub = sinon . stub ( exportMarketplaceApps , 'getAppManifestAndAppConfig' ) . resolves ( ) ;
@@ -196,6 +210,7 @@ describe('ExportMarketplaceApps', () => {
196210 expect ( exportMarketplaceApps . query ) . to . deep . equal ( { target_uids : 'test-stack-uid' } ) ;
197211 expect ( exportMarketplaceApps . appSdk ) . to . equal ( mockAppSdk ) ;
198212
213+ setupPathsStub . restore ( ) ;
199214 exportAppsStub . restore ( ) ;
200215 getAppManifestAndAppConfigStub . restore ( ) ;
201216 getAppsCountStub . restore ( ) ;
@@ -339,6 +354,8 @@ describe('ExportMarketplaceApps', () => {
339354 configuration : { key : 'value' } ,
340355 } ,
341356 ] ;
357+ // Set nodeCrypto so createNodeCryptoInstance is not called (stub may be bypassed when source imports via utils barrel in CI, causing timeout)
358+ exportMarketplaceApps . nodeCrypto = mockNodeCrypto ;
342359
343360 const getStackSpecificAppsStub = sinon . stub ( exportMarketplaceApps , 'getStackSpecificApps' ) . resolves ( ) ;
344361 const getAppManifestAndAppConfigStub = sinon . stub ( exportMarketplaceApps , 'getAppManifestAndAppConfig' ) . resolves ( ) ;
@@ -723,6 +740,7 @@ describe('ExportMarketplaceApps', () => {
723740 } ) ;
724741
725742 it ( 'should initialize NodeCrypto if not already initialized' , async ( ) => {
743+ // Rely on beforeEach stub of marketplaceAppHelper.createNodeCryptoInstance; set nodeCrypto undefined so the code path runs
726744 exportMarketplaceApps . nodeCrypto = undefined ;
727745 const installationData = {
728746 data : {
@@ -738,8 +756,9 @@ describe('ExportMarketplaceApps', () => {
738756
739757 await exportMarketplaceApps . getAppConfigurations ( 0 , exportMarketplaceApps . installedApps [ 0 ] ) ;
740758
741- expect ( ( marketplaceAppHelper . createNodeCryptoInstance as sinon . SinonStub ) . called ) . to . be . true ;
759+ // When stub applies: createNodeCryptoInstance was called and nodeCrypto is set
742760 expect ( exportMarketplaceApps . nodeCrypto ) . to . exist ;
761+ expect ( ( marketplaceAppHelper . createNodeCryptoInstance as sinon . SinonStub ) . called ) . to . be . true ;
743762 } ) ;
744763
745764 it ( 'should handle empty configuration gracefully' , async ( ) => {
0 commit comments