Skip to content

Commit d7187e4

Browse files
committed
fix yarn test
1 parent 29b3359 commit d7187e4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/@react-native-windows/cli/src/e2etest/architecturePrompt.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ const mockPrompts = prompts as jest.MockedFunction<typeof prompts>;
1616

1717
describe('architecturePrompt', () => {
1818
beforeEach(() => {
19+
jest.useFakeTimers(); // ensure timers are controlled
1920
jest.clearAllMocks();
2021
// Mock console methods to prevent output during tests
2122
jest.spyOn(console, 'log').mockImplementation(() => {});
2223
});
2324

2425
afterEach(() => {
26+
// flush any pending timers from the timeout in promptForArchitectureChoice
27+
jest.runOnlyPendingTimers();
28+
jest.useRealTimers();
2529
jest.restoreAllMocks();
2630
});
2731

packages/@react-native-windows/cli/src/utils/architecturePrompt.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ export async function promptForArchitectureChoice(
7676
'\n⏳ No input received in 3 seconds. Proceeding with Old Architecture by default.',
7777
),
7878
);
79-
resolve({ choice: 'y' });
79+
resolve({choice: 'y'});
8080
}, 3000);
8181
});
8282

8383
const response = await Promise.race([userInputPromise, timeoutPromise]);
8484

85-
clearTimeout(timeoutId); // prevent late logging after resolution
85+
if (timeoutId) clearTimeout(timeoutId); // prevent late logging after resolution
8686

8787
if (!response.choice) {
8888
// User cancelled or no input

0 commit comments

Comments
 (0)