diff --git a/Makefile b/Makefile
index b264860e958c..6a2c96876f92 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,9 @@ check-style: .yarninstall
yarn run check
test: .yarninstall
- cd $(BUILD_SERVER_DIR) && $(MAKE) internal-test-web-client
+ @echo Running jest unit/component testing
+
+ yarn run test
.yarninstall: package.json
@echo Getting dependencies using yarn
diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md
index fb4ac3f36ebd..0c5c04ac79f7 100644
--- a/PULL_REQUEST_TEMPLATE.md
+++ b/PULL_REQUEST_TEMPLATE.md
@@ -11,6 +11,7 @@ When filling in a section please remove the help text and the above text.
#### Checklist
[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]
- [ ] Ran `make check-style` to check for style errors (required for all pull requests)
+- [ ] Ran `make test` to ensure unit and component tests passed
- [ ] Added or updated unit tests (required for all new features)
- [ ] Has server changes (please link)
- [ ] Has redux changes (please link)
diff --git a/build/Jenkinsfile b/build/Jenkinsfile
index 96f433219c95..a961a0265b17 100644
--- a/build/Jenkinsfile
+++ b/build/Jenkinsfile
@@ -33,6 +33,13 @@ podTemplate(label: 'jenkins-slave-webapp',
}
}
}
+ stage('Unit/Component Tests') {
+ container('mattermost-node') {
+ dir('mattermost-webapp') {
+ sh 'make test'
+ }
+ }
+ }
stage('Build') {
container('mattermost-node') {
dir('mattermost-webapp') {
diff --git a/package.json b/package.json
index 8655d655d602..7230d7d1b030 100644
--- a/package.json
+++ b/package.json
@@ -70,7 +70,7 @@
"cross-env": "5.1.1",
"css-loader": "0.28.7",
"enzyme": "3.1.1",
- "enzyme-adapter-react-15": "1.0.5",
+ "enzyme-adapter-react-16": "1.1.0",
"enzyme-to-json": "3.2.2",
"eslint": "3.17.1",
"eslint-import-resolver-webpack": "0.8.3",
@@ -114,12 +114,15 @@
"/node_modules/",
"/non_npm_dependencies/"
],
+ "clearMocks": true,
"collectCoverageFrom": [
"actions/**/*.{js,jsx}",
"client/**/*.{js,jsx}",
"components/**/*.jsx",
"plugins/**/*.{js,jsx}",
+ "reducers/**/*.{js,jsx}",
"routes/**/*.{js,jsx}",
+ "selectors/**/*.{js,jsx}",
"stores/**/*.{js,jsx}",
"utils/**/*.{js,jsx}"
],
diff --git a/tests/components/about_build_modal.test.jsx b/tests/components/about_build_modal.test.jsx
index d7cccf1bc7f3..7b6af8812193 100644
--- a/tests/components/about_build_modal.test.jsx
+++ b/tests/components/about_build_modal.test.jsx
@@ -3,7 +3,6 @@
import React from 'react';
import {Modal} from 'react-bootstrap';
-
import {shallow} from 'enzyme';
import {mountWithIntl} from 'tests/helpers/intl-test-helper.jsx';
diff --git a/tests/components/audio_video_preview.test.jsx b/tests/components/audio_video_preview.test.jsx
index c7a388d10af1..4d2c00b18731 100644
--- a/tests/components/audio_video_preview.test.jsx
+++ b/tests/components/audio_video_preview.test.jsx
@@ -16,10 +16,6 @@ describe('component/AudioVideoPreview', () => {
fileUrl: '/api/v4/files/file_id'
};
- afterAll(() => {
- jest.clearAllMocks();
- });
-
test('should match snapshot without children', () => {
const wrapper = shallow(
diff --git a/tests/components/channel_info_modal.test.jsx b/tests/components/channel_info_modal.test.jsx
index c6c92b117dd7..e9be049e8278 100644
--- a/tests/components/channel_info_modal.test.jsx
+++ b/tests/components/channel_info_modal.test.jsx
@@ -3,7 +3,6 @@
import React from 'react';
import {Modal} from 'react-bootstrap';
-
import {shallow} from 'enzyme';
import {mountWithIntl} from 'tests/helpers/intl-test-helper.jsx';
diff --git a/tests/components/get_link_modal.test.jsx b/tests/components/get_link_modal.test.jsx
index 0f02a0925970..273b434d8100 100644
--- a/tests/components/get_link_modal.test.jsx
+++ b/tests/components/get_link_modal.test.jsx
@@ -2,7 +2,6 @@
// See License.txt for license information.
import React from 'react';
-
import {shallow} from 'enzyme';
import {Modal} from 'react-bootstrap';
diff --git a/tests/components/integrations/__snapshots__/installed_command.test.jsx.snap b/tests/components/integrations/__snapshots__/installed_command.test.jsx.snap
index c23dd61e7e8a..58b24019cb8f 100644
--- a/tests/components/integrations/__snapshots__/installed_command.test.jsx.snap
+++ b/tests/components/integrations/__snapshots__/installed_command.test.jsx.snap
@@ -101,287 +101,103 @@ exports[`components/integrations/InstalledCommand should call onDelete function
`;
exports[`components/integrations/InstalledCommand should call onRegenToken function 1`] = `
-
-
-
- display_name
-
-
- - /trigger auto_complete_hint
-
-
-
+
-
- description
-
-
-
+
+
+
-
-
-
- Token: testToken
-
-
-
-
-
+
+
+
-
-
-
- Created by username on Tuesday, July 11, 2017
-
-
-
-
+ }
+ />
+
-
- -
-
-
-
-
- Edit
-
-
-
-
- -
-
-
-
-
- }
- message={
-
-
-
-
- }
- modalClass=""
- onCancel={[Function]}
- onConfirm={[Function]}
- onKeyDown={[Function]}
- show={false}
- title={
-
+ defaultMessage="Created by {creator} on {createAt, date, full}"
+ id="installed_integrations.creation"
+ values={
+ Object {
+ "createAt": "1499722850203",
+ "creator": "username",
}
- >
-
-
-
-
-
-
+ }
+ />
+
-
+
+
+ -
+
+
+
+ -
+
+
+
`;
exports[`components/integrations/InstalledCommand should filter out command 1`] = `""`;
diff --git a/tests/components/integrations/installed_command.test.jsx b/tests/components/integrations/installed_command.test.jsx
index b2311eeb185c..25d01110fca3 100644
--- a/tests/components/integrations/installed_command.test.jsx
+++ b/tests/components/integrations/installed_command.test.jsx
@@ -2,11 +2,8 @@
// See License.txt for license information.
import React from 'react';
-
import {shallow} from 'enzyme';
-import {mountWithIntl} from 'tests/helpers/intl-test-helper';
-
import InstalledCommand from 'components/integrations/components/installed_command.jsx';
describe('components/integrations/InstalledCommand', () => {
@@ -64,10 +61,10 @@ describe('components/integrations/InstalledCommand', () => {
const canChange = true;
const props = {...requiredProps, onRegenToken, canChange};
- const wrapper = mountWithIntl();
+ const wrapper = shallow();
expect(wrapper).toMatchSnapshot();
- wrapper.find('div.item-actions button').first().simulate('click');
+ wrapper.find('div.item-actions button').first().simulate('click', {preventDefault: jest.fn()});
expect(onRegenToken).toHaveBeenCalledTimes(1);
expect(onRegenToken).toHaveBeenCalledWith(props.command);
});
diff --git a/tests/components/integrations/installed_outgoing_webhooks.test.jsx b/tests/components/integrations/installed_outgoing_webhooks.test.jsx
index 773bf60f1d60..6b2955c6cea5 100644
--- a/tests/components/integrations/installed_outgoing_webhooks.test.jsx
+++ b/tests/components/integrations/installed_outgoing_webhooks.test.jsx
@@ -13,8 +13,8 @@ describe('components/integrations/InstalledOutgoingWebhooks', () => {
const teamId = 'testteamid';
beforeEach(() => {
mockFunc = jest.fn();
- outgoingWebhooks = {
- '7h88x419ubbyuxzs7dfwtgkffr': {
+ outgoingWebhooks = [
+ {
callback_urls: ['http://adsfdasd.com'],
channel_id: 'mdpzfpfcxi85zkkqkzkch4b85h',
content_type: 'application/x-www-form-urlencoded',
@@ -31,7 +31,7 @@ describe('components/integrations/InstalledOutgoingWebhooks', () => {
0: 'asdf',
update_at: 1508329149618
},
- '7h88x419ubbyuxzs7dfwtgkfff': {
+ {
callback_urls: ['http://adsfdasd.com'],
channel_id: 'mdpzfpfcxi85zkkqkzkch4b85h',
content_type: 'application/x-www-form-urlencoded',
@@ -48,7 +48,7 @@ describe('components/integrations/InstalledOutgoingWebhooks', () => {
0: 'asdf',
update_at: 1508329149618
}
- };
+ ];
});
test('should match snapshot', () => {
diff --git a/tests/components/pdf_preview.test.jsx b/tests/components/pdf_preview.test.jsx
index eacca69bbeac..5cf88a302904 100644
--- a/tests/components/pdf_preview.test.jsx
+++ b/tests/components/pdf_preview.test.jsx
@@ -23,10 +23,6 @@ describe('component/PDFPreview', () => {
fileUrl: 'https://pre-release.mattermost.com/api/v4/files/ips59w4w9jnfbrs3o94m1dbdie'
};
- afterAll(() => {
- jest.clearAllMocks();
- });
-
test('should match snapshot, loading', () => {
const wrapper = shallow(
diff --git a/tests/plugins/__snapshots__/pluggable.test.jsx.snap b/tests/plugins/__snapshots__/pluggable.test.jsx.snap
index eab18aabf279..96a3bb25a36c 100644
--- a/tests/plugins/__snapshots__/pluggable.test.jsx.snap
+++ b/tests/plugins/__snapshots__/pluggable.test.jsx.snap
@@ -163,7 +163,6 @@ exports[`plugins/Pluggable should match snapshot with no overridden component 1`