File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
packages/@react-native-windows/cli/src Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -16,12 +16,16 @@ const mockPrompts = prompts as jest.MockedFunction<typeof prompts>;
16
16
17
17
describe ( 'architecturePrompt' , ( ) => {
18
18
beforeEach ( ( ) => {
19
+ jest . useFakeTimers ( ) ; // ensure timers are controlled
19
20
jest . clearAllMocks ( ) ;
20
21
// Mock console methods to prevent output during tests
21
22
jest . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } ) ;
22
23
} ) ;
23
24
24
25
afterEach ( ( ) => {
26
+ // flush any pending timers from the timeout in promptForArchitectureChoice
27
+ jest . runOnlyPendingTimers ( ) ;
28
+ jest . useRealTimers ( ) ;
25
29
jest . restoreAllMocks ( ) ;
26
30
} ) ;
27
31
Original file line number Diff line number Diff line change @@ -76,13 +76,13 @@ export async function promptForArchitectureChoice(
76
76
'\n⏳ No input received in 3 seconds. Proceeding with Old Architecture by default.' ,
77
77
) ,
78
78
) ;
79
- resolve ( { choice : 'y' } ) ;
79
+ resolve ( { choice : 'y' } ) ;
80
80
} , 3000 ) ;
81
81
} ) ;
82
82
83
83
const response = await Promise . race ( [ userInputPromise , timeoutPromise ] ) ;
84
84
85
- clearTimeout ( timeoutId ) ; // prevent late logging after resolution
85
+ if ( timeoutId ) clearTimeout ( timeoutId ) ; // prevent late logging after resolution
86
86
87
87
if ( ! response . choice ) {
88
88
// User cancelled or no input
You can’t perform that action at this time.
0 commit comments