diff --git a/.circleci/config.yml b/.circleci/config.yml
index 2da04347c..57dd968ca 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -404,7 +404,7 @@ jobs:
- run:
name: Test
command: |
- yarn test -w 8
+ yarn test --runInBand
- run:
name: Codecov
diff --git a/app/views/CreateChannelView/RoomSettings/SwitchItemEncrypted.test.tsx b/app/views/CreateChannelView/RoomSettings/SwitchItemEncrypted.test.tsx
index f6705b505..a5f536d5a 100644
--- a/app/views/CreateChannelView/RoomSettings/SwitchItemEncrypted.test.tsx
+++ b/app/views/CreateChannelView/RoomSettings/SwitchItemEncrypted.test.tsx
@@ -1,39 +1,25 @@
import React from 'react';
-import { fireEvent, render } from '@testing-library/react-native';
-import { Provider } from 'react-redux';
+import { fireEvent, render, screen } from '@testing-library/react-native';
-import { SwitchItemEncrypted, ISwitchItemEncrypted } from './SwitchItemEncrypted';
-import { mockedStore as store } from '../../../reducers/mockedStore';
import i18n from '../../../i18n';
+import { SwitchItemEncrypted } from './SwitchItemEncrypted';
const onPressMock = jest.fn((value: boolean) => value);
-const testEncrypted = {
- encrypted: false,
- encryptionEnabled: false,
- isTeam: false,
- onValueChangeEncrypted: onPressMock,
- type: false,
- testSwitchID: 'create-channel-encrypted',
- testLabelID: `create-channel-encrypted-hint`
-};
-
-const Render = ({ encrypted, encryptionEnabled, isTeam, onValueChangeEncrypted, type }: ISwitchItemEncrypted) => (
-
-
-
-);
-
describe('SwitchItemEncrypted', () => {
- it('should not render the Encrypted Switch component', async () => {
- const { findByTestId } = render(
- {
+ render(
+ {
type={testEncrypted.type}
/>
);
- try {
- await findByTestId(testEncrypted.testSwitchID);
- } catch (e) {
- expect(e).toBeTruthy();
- }
+ const component = screen.queryByTestId(testEncrypted.testSwitchID);
+ expect(component).toBeNull();
});
- it('should render the Encrypted Switch component', async () => {
+
+ it('should render the Encrypted Switch component', () => {
testEncrypted.encryptionEnabled = true;
- const { findByTestId } = render(
- {
type={testEncrypted.type}
/>
);
- const component = await findByTestId(testEncrypted.testSwitchID);
+ const component = screen.queryByTestId(testEncrypted.testSwitchID);
expect(component).toBeTruthy();
});
- it('should change value of switch', async () => {
- const { findByTestId } = render(
- {
+ render(
+ {
type={testEncrypted.type}
/>
);
-
- const component = await findByTestId(testEncrypted.testSwitchID);
- fireEvent(component, 'valueChange', { value: true });
- expect(onPressMock).toHaveReturnedWith({ value: !testEncrypted.encrypted });
+ const component = screen.queryByTestId(testEncrypted.testSwitchID);
+ if (component) {
+ fireEvent(component, 'valueChange', { value: true });
+ expect(onPressMock).toHaveReturnedWith({ value: !testEncrypted.encrypted });
+ }
});
- it('label when encrypted and isTeam are false and is a public channel', async () => {
- const { findByTestId } = render(
- {
+ render(
+ {
type={testEncrypted.type}
/>
);
- const component = await findByTestId(testEncrypted.testLabelID);
- expect(component.props.children).toBe(i18n.t('Channel_hint_encrypted_not_available'));
+ const component = screen.queryByTestId(testEncrypted.testLabelID);
+ expect(component?.props.children).toBe(i18n.t('Channel_hint_encrypted_not_available'));
});
- it('label when encrypted and isTeam are true and is a private team', async () => {
+
+ it('label when encrypted and isTeam are true and is a private team', () => {
testEncrypted.isTeam = true;
testEncrypted.type = true;
testEncrypted.encrypted = true;
- const { findByTestId } = render(
- {
type={testEncrypted.type}
/>
);
- const component = await findByTestId(testEncrypted.testLabelID);
- expect(component.props.children).toBe(i18n.t('Team_hint_encrypted'));
+ const component = screen.queryByTestId(testEncrypted.testLabelID);
+ expect(component?.props.children).toBe(i18n.t('Team_hint_encrypted'));
});
});
diff --git a/jest.config.js b/jest.config.js
new file mode 100644
index 000000000..9bea4c596
--- /dev/null
+++ b/jest.config.js
@@ -0,0 +1,14 @@
+module.exports = {
+ testPathIgnorePatterns: ['e2e', 'node_modules'],
+ transformIgnorePatterns: [
+ 'node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)'
+ ],
+ preset: './jest.preset.js',
+ coverageDirectory: './coverage/',
+ collectCoverage: true,
+ moduleNameMapper: {
+ '.+\\.(css|styl|less|sass|scss)$': 'identity-obj-proxy',
+ '.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '/__mocks__/fileMock.js'
+ },
+ setupFilesAfterEnv: ['./jest.setup.js']
+};
diff --git a/jest.setup.js b/jest.setup.js
index 2ea537aa7..e8e2bcfcd 100644
--- a/jest.setup.js
+++ b/jest.setup.js
@@ -1,3 +1,6 @@
+// https://github.com/facebook/react/issues/20756#issuecomment-780927519
+import 'react-16-node-hanging-test-fix';
+
import React from 'react';
import '@testing-library/react-native/extend-expect';
import mockClipboard from '@react-native-clipboard/clipboard/jest/clipboard-mock.js';
diff --git a/package.json b/package.json
index 2702198de..43ccf22b0 100644
--- a/package.json
+++ b/package.json
@@ -148,7 +148,7 @@
"use-debounce": "^8.0.4",
"use-deep-compare-effect": "1.6.1",
"xregexp": "5.0.2",
- "yup": "^0.32.11"
+ "yup": "0.32.11"
},
"resolutions": {
"ua-parser-js": "^1.0.2",
@@ -210,6 +210,7 @@
"otp.js": "1.2.0",
"patch-package": "8.0.0",
"prettier": "^2.3.2",
+ "react-16-node-hanging-test-fix": "^1.0.0",
"react-dom": "17.0.1",
"react-native-dotenv": "3.4.8",
"react-test-renderer": "17.0.2",
@@ -218,25 +219,6 @@
"ts-node": "^10.9.1",
"typescript": "^4.3.5"
},
- "jest": {
- "testPathIgnorePatterns": [
- "e2e",
- "node_modules"
- ],
- "transformIgnorePatterns": [
- "node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)"
- ],
- "preset": "./jest.preset.js",
- "coverageDirectory": "./coverage/",
- "collectCoverage": true,
- "moduleNameMapper": {
- ".+\\.(css|styl|less|sass|scss)$": "identity-obj-proxy",
- ".+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/__mocks__/fileMock.js"
- },
- "setupFilesAfterEnv": [
- "./jest.setup.js"
- ]
- },
"jest-junit": {
"addFileAttribute": "true"
},
diff --git a/patches/react-16-node-hanging-test-fix+1.0.0.patch b/patches/react-16-node-hanging-test-fix+1.0.0.patch
new file mode 100644
index 000000000..98285b046
--- /dev/null
+++ b/patches/react-16-node-hanging-test-fix+1.0.0.patch
@@ -0,0 +1,13 @@
+diff --git a/node_modules/react-16-node-hanging-test-fix/index.js b/node_modules/react-16-node-hanging-test-fix/index.js
+index 4a3b342..442eef1 100644
+--- a/node_modules/react-16-node-hanging-test-fix/index.js
++++ b/node_modules/react-16-node-hanging-test-fix/index.js
+@@ -16,7 +16,7 @@ if (Object.prototype.toString.call(process) !== '[object process]') {
+ );
+ }
+
+-if (semverGt(version, '17.0.1')) {
++if (semverGt(version, '17.0.2')) {
+ console.error(
+ 'The `react-16-node-hanging-test-fix` package is no longer needed ' +
+ 'with React ' + version + ' and may cause issues. Remove this import.'
diff --git a/yarn.lock b/yarn.lock
index 3deaca6aa..3abd0c30d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -17559,6 +17559,13 @@ rc@~1.2.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"
+react-16-node-hanging-test-fix@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/react-16-node-hanging-test-fix/-/react-16-node-hanging-test-fix-1.0.0.tgz#9fef3f7d983789d64971311d3cd17116849a56b3"
+ integrity sha512-D22iNNa+0MuMPA49nZ5ILBHiJ7h9PTeUUuZee38pFSEWlHOYnHEWzUjOlYjEo6Ji+axHrRnT+y1QRIJOcIcj4w==
+ dependencies:
+ semver "^7.3.4"
+
react-colorful@^5.1.2:
version "5.6.0"
resolved "https://registry.yarnpkg.com/react-colorful/-/react-colorful-5.6.0.tgz#1394165de401265d36a809a7ac87c910fad36837"
@@ -21763,7 +21770,7 @@ yocto-queue@^0.1.0:
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
-yup@^0.32.11:
+yup@0.32.11:
version "0.32.11"
resolved "https://registry.yarnpkg.com/yup/-/yup-0.32.11.tgz#d67fb83eefa4698607982e63f7ca4c5ed3cf18c5"
integrity sha512-Z2Fe1bn+eLstG8DRR6FTavGD+MeAwyfmouhHsIUgaADz8jvFKbO/fXc2trJKZg+5EBjh4gGm3iU/t3onKlXHIg==