11// Load environment variables from .env file if it exists
2- import { config } from ' dotenv' ;
3- import { existsSync } from 'fs' ;
4- import { join } from ' path' ;
2+ import { config } from " dotenv" ;
3+ import { existsSync } from "fs" ;
4+ import { join } from " path" ;
55
66// Load .env file if it exists
7- const envPath = join ( process . cwd ( ) , ' .env' ) ;
7+ const envPath = join ( process . cwd ( ) , " .env" ) ;
88if ( existsSync ( envPath ) ) {
99 config ( { path : envPath } ) ;
1010}
1111
12- // Set default test environment variables
13- process . env . RUNLOOP_ENV = process . env . RUNLOOP_ENV || 'dev' ;
14- process . env . RUNLOOP_API_KEY = process . env . RUNLOOP_API_KEY || 'ak_30tbdSzn9RNLxkrgpeT81' ;
15- process . env . RUNLOOP_BASE_URL = process . env . RUNLOOP_BASE_URL || 'https://api.runloop.pro' ;
16- process . env . NODE_ENV = process . env . NODE_ENV || 'test' ;
17-
1812// Mock console methods for cleaner test output (only for unit tests)
1913if ( ! process . env . RUN_E2E ) {
2014 const originalConsole = global . console ;
@@ -36,19 +30,19 @@ if (!process.env.RUN_E2E) {
3630
3731// Add pending function for integration tests
3832global . pending = ( reason ?: string ) => {
39- throw new Error ( `Test pending: ${ reason || ' No reason provided' } ` ) ;
33+ throw new Error ( `Test pending: ${ reason || " No reason provided" } ` ) ;
4034} ;
4135
4236// Mock interactive command runner to prevent Ink issues in tests
43- jest . mock ( ' ../src/utils/interactiveCommand.js' , ( ) => ( {
37+ jest . mock ( " ../src/utils/interactiveCommand.js" , ( ) => ( {
4438 runInteractiveCommand : jest . fn ( async ( fn ) => {
4539 // Just run the function directly without Ink
4640 return await fn ( ) ;
4741 } ) ,
4842} ) ) ;
4943
5044// Mock Ink components to prevent raw mode issues
51- jest . mock ( ' ink' , ( ) => ( {
45+ jest . mock ( " ink" , ( ) => ( {
5246 render : jest . fn ( ) ,
5347 Box : ( { children } : any ) => children ,
5448 Text : ( { children } : any ) => children ,
@@ -63,12 +57,27 @@ jest.mock('ink', () => ({
6357} ) ) ;
6458
6559// Mock ESM-only Ink dependencies so Jest doesn't parse their ESM bundles
66- jest . mock ( ' ink-big-text' , ( ) => ( { __esModule : true , default : ( ) => null } ) ) ;
67- jest . mock ( ' ink-gradient' , ( ) => ( { __esModule : true , default : ( ) => null } ) ) ;
60+ jest . mock ( " ink-big-text" , ( ) => ( { __esModule : true , default : ( ) => null } ) ) ;
61+ jest . mock ( " ink-gradient" , ( ) => ( { __esModule : true , default : ( ) => null } ) ) ;
6862
6963// Mock app UI components that import Ink deps, to avoid pulling in ESM from node_modules
70- jest . mock ( '../src/components/Banner.tsx' , ( ) => ( { __esModule : true , Banner : ( ) => null } ) ) ;
71- jest . mock ( '../src/components/Header.tsx' , ( ) => ( { __esModule : true , Header : ( ) => null } ) ) ;
72- jest . mock ( '../src/components/Spinner.tsx' , ( ) => ( { __esModule : true , SpinnerComponent : ( ) => null } ) ) ;
73- jest . mock ( '../src/components/SuccessMessage.tsx' , ( ) => ( { __esModule : true , SuccessMessage : ( ) => null } ) ) ;
74- jest . mock ( '../src/components/ErrorMessage.tsx' , ( ) => ( { __esModule : true , ErrorMessage : ( ) => null } ) ) ;
64+ jest . mock ( "../src/components/Banner.tsx" , ( ) => ( {
65+ __esModule : true ,
66+ Banner : ( ) => null ,
67+ } ) ) ;
68+ jest . mock ( "../src/components/Header.tsx" , ( ) => ( {
69+ __esModule : true ,
70+ Header : ( ) => null ,
71+ } ) ) ;
72+ jest . mock ( "../src/components/Spinner.tsx" , ( ) => ( {
73+ __esModule : true ,
74+ SpinnerComponent : ( ) => null ,
75+ } ) ) ;
76+ jest . mock ( "../src/components/SuccessMessage.tsx" , ( ) => ( {
77+ __esModule : true ,
78+ SuccessMessage : ( ) => null ,
79+ } ) ) ;
80+ jest . mock ( "../src/components/ErrorMessage.tsx" , ( ) => ( {
81+ __esModule : true ,
82+ ErrorMessage : ( ) => null ,
83+ } ) ) ;
0 commit comments