File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed
Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change 11const { setupBilling, OrmType } = require ( "fdk-billing-javascript" ) ;
22const mongoose = require ( 'mongoose' ) ;
33
4- // Connect to MongoDB (using local MongoDB or MongoDB Atlas)
5- const MONGODB_URI = process . env . MONGODB_URI || 'mongodb://localhost:27017/fynd-extension-billing' ;
4+ // Only connect to MongoDB if we're not in test environment
5+ if ( process . env . NODE_ENV !== 'test' ) {
6+ const MONGODB_URI = process . env . MONGODB_URI || 'mongodb://localhost:27017/fynd-extension-billing' ;
7+
8+ mongoose . connect ( MONGODB_URI )
9+ . then ( ( ) => {
10+ console . log ( 'Connected to MongoDB for billing' ) ;
11+ } )
12+ . catch ( ( error ) => {
13+ console . error ( 'MongoDB connection error:' , error ) ;
14+ } ) ;
15+ }
616
7- // Connect to MongoDB (removed deprecated options)
8- mongoose . connect ( MONGODB_URI )
9- . then ( ( ) => {
10- console . log ( 'Connected to MongoDB for billing' ) ;
11- } )
12- . catch ( ( error ) => {
13- console . error ( 'MongoDB connection error:' , error ) ;
14- } ) ;
15-
16- // Initialize billing instance
17+ // Initialize billing instance with fallback for tests
1718const fdkBillingInstance = setupBilling ( {
18- extension_id : process . env . EXTENSION_API_KEY ,
19+ extension_id : process . env . EXTENSION_API_KEY || "test-extension-key" ,
1920 db_connection : mongoose . connection ,
2021 collection_name : {
2122 plan : "plans" ,
You can’t perform that action at this time.
0 commit comments