Skip to content

Commit 81181f2

Browse files
committed
[number field] Skip the owner stack spy when React cannot provide one
1 parent 29797f3 commit 81181f2

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

packages/react/src/number-field/input/NumberFieldInput.test.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,11 @@ describe('<NumberField.Input />', () => {
14221422

14231423
it('warns without an owner stack when React cannot provide one', async () => {
14241424
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
1425-
const ownerStackSpy = vi.spyOn(SafeReact, 'captureOwnerStack').mockReturnValue(null);
1425+
// React below 19.1 doesn't expose `captureOwnerStack` at all, which is the very
1426+
// condition under test, so there is nothing to stub on those versions.
1427+
const ownerStackSpy = SafeReact.captureOwnerStack
1428+
? vi.spyOn(SafeReact, 'captureOwnerStack').mockReturnValue(null)
1429+
: null;
14261430

14271431
try {
14281432
await render(
@@ -1441,7 +1445,7 @@ describe('<NumberField.Input />', () => {
14411445
'Base UI: <NumberField.Input> could not read clipboard text during paste handling. ',
14421446
);
14431447
} finally {
1444-
ownerStackSpy.mockRestore();
1448+
ownerStackSpy?.mockRestore();
14451449
warnSpy.mockRestore();
14461450
}
14471451
});

0 commit comments

Comments
 (0)