From 84e84d2c9d33d58f8caa37489dd88c8725d3c721 Mon Sep 17 00:00:00 2001 From: sunderls <2394070+sunderls@users.noreply.github.com> Date: Sun, 6 Feb 2022 21:55:58 +0000 Subject: [PATCH 1/2] update node.js version for CI --- .circleci/config.yml | 2 +- .../react-dom/src/__tests__/ReactTestUtilsAct-test.js | 10 +++++++--- .../src/__tests__/useSyncExternalStoreShared-test.js | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a9905a53b7a9f..2e54806b6ffff 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2.1 aliases: - &docker - - image: cimg/openjdk:17.0.0-node + - image: cimg/openjdk:17.0.2-node - &environment TZ: /usr/share/zoneinfo/America/Los_Angeles diff --git a/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js b/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js index 71adc286d08ba..db8562060f4ad 100644 --- a/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js +++ b/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js @@ -503,9 +503,13 @@ function runActTests(label, render, unmount, rerender) { spyOnDevAndProd(console, 'error'); // let's try to cheat and spin off a 'thread' with an act call (async () => { - await act(async () => { - await sleep(50); - }); + try { + await act(async () => { + await sleep(50); + }); + } catch (e) { + // suppress ERR_UNHANDLED_REJECTION + } })(); await act(async () => { diff --git a/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShared-test.js b/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShared-test.js index cb3a40aa13ab7..ca5c7c0b5b916 100644 --- a/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShared-test.js +++ b/packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShared-test.js @@ -899,7 +899,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => { store.set({}); }); expect(container.textContent).toEqual( - "Cannot read property 'toUpperCase' of undefined", + "Cannot read properties of undefined (reading 'toUpperCase')", ); }); @@ -935,7 +935,7 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => { store.set({}); }); expect(container.textContent).toEqual( - "Cannot read property 'trim' of undefined", + "Cannot read properties of undefined (reading 'trim')", ); }); }); From 45564d3c0151475e474017f3a5dc259dac984f5b Mon Sep 17 00:00:00 2001 From: sunderls <2394070+sunderls@users.noreply.github.com> Date: Mon, 7 Feb 2022 21:50:29 +0000 Subject: [PATCH 2/2] use __DEV__ --- .../react-dom/src/__tests__/ReactTestUtilsAct-test.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js b/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js index db8562060f4ad..42c6da3d955e0 100644 --- a/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js +++ b/packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js @@ -502,15 +502,14 @@ function runActTests(label, render, unmount, rerender) { it('warns if you try to interleave multiple act calls', async () => { spyOnDevAndProd(console, 'error'); // let's try to cheat and spin off a 'thread' with an act call - (async () => { - try { + // uncaught rejection causes error since node.js v15 so it is gated here + if (__DEV__) { + (async () => { await act(async () => { await sleep(50); }); - } catch (e) { - // suppress ERR_UNHANDLED_REJECTION - } - })(); + })(); + } await act(async () => { await sleep(100);