From 99b8193ce7a33f26ae08667d354f26ed1ef2f3dd Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 17 Sep 2019 14:33:32 -0600 Subject: [PATCH 1/2] Use the new ShallowRenderer over ReactTestUtils Mostly because the ReactTestUtils renderer doesn't exist anymore. --- package.json | 1 + .../views/elements/MemberEventListSummary-test.js | 4 ++-- test/test-utils.js | 5 +++++ yarn.lock | 15 +++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 070abf352d..0e41d4c38a 100644 --- a/package.json +++ b/package.json @@ -150,6 +150,7 @@ "matrix-mock-request": "^1.2.3", "matrix-react-test-utils": "^0.2.2", "mocha": "^5.0.5", + "react-test-renderer": "^16.9.0", "require-json": "0.0.1", "rimraf": "^2.4.3", "sinon": "^5.0.7", diff --git a/test/components/views/elements/MemberEventListSummary-test.js b/test/components/views/elements/MemberEventListSummary-test.js index d1e112735d..09a4739f06 100644 --- a/test/components/views/elements/MemberEventListSummary-test.js +++ b/test/components/views/elements/MemberEventListSummary-test.js @@ -112,7 +112,7 @@ describe('MemberEventListSummary', function() { threshold: 3, }; - const renderer = ReactTestUtils.createRenderer(); + const renderer = testUtils.getRenderer(); renderer.render(); const result = renderer.getRenderOutput(); @@ -134,7 +134,7 @@ describe('MemberEventListSummary', function() { threshold: 3, }; - const renderer = ReactTestUtils.createRenderer(); + const renderer = testUtils.getRenderer(); renderer.render(); const result = renderer.getRenderOutput(); diff --git a/test/test-utils.js b/test/test-utils.js index f60cab3bc2..ff800132b9 100644 --- a/test/test-utils.js +++ b/test/test-utils.js @@ -9,6 +9,7 @@ import dis from '../src/dispatcher'; import jssdk from 'matrix-js-sdk'; import {makeType} from "../src/utils/TypeUtils"; import {ValidatedServerConfig} from "../src/utils/AutoDiscoveryUtils"; +import ShallowRenderer from 'react-test-renderer/shallow'; const MatrixEvent = jssdk.MatrixEvent; /** @@ -31,6 +32,10 @@ export function beforeEach(context) { console.log(new Array(1 + desc.length).join("=")); } +export function getRenderer() { + // Old: ReactTestUtils.createRenderer(); + return new ShallowRenderer(); +} /** * Stub out the MatrixClient, and configure the MatrixClientPeg object to diff --git a/yarn.lock b/yarn.lock index 712de0b2b4..4789b22041 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6404,6 +6404,11 @@ react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4: resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16" integrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA== +react-is@^16.9.0: + version "16.9.0" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.9.0.tgz#21ca9561399aad0ff1a7701c01683e8ca981edcb" + integrity sha512-tJBzzzIgnnRfEm046qRcURvwQnZVXmuCbscxUO5RWrGTXpon2d4c8mI0D8WE6ydVIm29JiLB6+RslkIvym9Rjw== + react-lifecycles-compat@^3.0.0: version "3.0.4" resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362" @@ -6431,6 +6436,16 @@ react-redux@^5.0.6: react-is "^16.6.0" react-lifecycles-compat "^3.0.0" +react-test-renderer@^16.9.0: + version "16.9.0" + resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.9.0.tgz#7ed657a374af47af88f66f33a3ef99c9610c8ae9" + integrity sha512-R62stB73qZyhrJo7wmCW9jgl/07ai+YzvouvCXIJLBkRlRqLx4j9RqcLEAfNfU3OxTGucqR2Whmn3/Aad6L3hQ== + dependencies: + object-assign "^4.1.1" + prop-types "^15.6.2" + react-is "^16.9.0" + scheduler "^0.15.0" + react-transition-group@^1.2.0: version "1.2.1" resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-1.2.1.tgz#e11f72b257f921b213229a774df46612346c7ca6" From 10b2501785ca27e193399696f03538e5ead35b7a Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 17 Sep 2019 14:37:59 -0600 Subject: [PATCH 2/2] Upgrade lolex to pull in a clock fix See https://github.com/sinonjs/lolex/issues/136 We don't use fake timers, but we do use lolex's clock, which probably causes the same thing. Jumping from 2.x to 4.x looks largely compatible - tests pass. --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 0e41d4c38a..958b782ac3 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "isomorphic-fetch": "^2.2.1", "linkifyjs": "^2.1.6", "lodash": "^4.17.14", - "lolex": "2.3.2", + "lolex": "4.2", "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop", "optimist": "^0.6.1", "pako": "^1.0.5", diff --git a/yarn.lock b/yarn.lock index 4789b22041..ac1adf1d20 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4930,10 +4930,10 @@ loglevel@1.6.1: resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.1.tgz#e0fc95133b6ef276cdc8887cdaf24aa6f156f8fa" integrity sha1-4PyVEztu8nbNyIh82vJKpvFW+Po= -lolex@2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/lolex/-/lolex-2.3.2.tgz#85f9450425103bf9e7a60668ea25dc43274ca807" - integrity sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng== +lolex@4.2: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lolex/-/lolex-4.2.0.tgz#ddbd7f6213ca1ea5826901ab1222b65d714b3cd7" + integrity sha512-gKO5uExCXvSm6zbF562EvM+rd1kQDnB9AZBbiQVzf1ZmdDpxUSvpnAaVOP83N/31mRK8Ml8/VE8DMvsAZQ+7wg== lolex@^2.4.2: version "2.7.5"