Skip to content

Commit

Permalink
Fix jest test and paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey Robertson committed May 5, 2020
1 parent f5ba2dd commit 2dab77b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
11 changes: 4 additions & 7 deletions x-pack/plugins/canvas/.storybook/storyshots.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import path from 'path';
import moment from 'moment';
import 'moment-timezone';
import ReactDOM from "react-dom";
import ReactDOM from 'react-dom';

import initStoryshots, { multiSnapshotWithOptions } from '@storybook/addon-storyshots';
import styleSheetSerializer from 'jest-styled-components/src/styleSheetSerializer';
Expand All @@ -25,8 +25,8 @@ moment.tz.setDefault('UTC');
const testTime = new Date(Date.UTC(2019, 5, 1)); // June 1 2019
Date.now = jest.fn(() => testTime);

// Mock telemetry service
jest.mock('../public/lib/ui_metric', () => ({ trackCanvasUiMetric: () => { } }));
// Mock telemetry service
jest.mock('../public/lib/ui_metric', () => ({ trackCanvasUiMetric: () => {} }));

// Mock EUI generated ids to be consistently predictable for snapshots.
jest.mock(`@elastic/eui/lib/components/form/form_row/make_id`, () => () => `generated-id`);
Expand Down Expand Up @@ -65,9 +65,8 @@ jest.mock('@elastic/eui/packages/react-datepicker', () => {
};
});


// Mock React Portal for components that use modals, tooltips, etc
ReactDOM.createPortal = jest.fn((element) => {
ReactDOM.createPortal = jest.fn(element => {
return element;
});

Expand All @@ -77,8 +76,6 @@ jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => {
};
});

jest.mock('plugins/interpreter/registries', () => ({}));

// Disabling this test due to https://github.com/elastic/eui/issues/2242
jest.mock(
'../public/components/workpad_header/share_menu/flyout/__examples__/share_website_flyout.stories',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

jest.mock('../../../legacy');
jest.mock('ui/new_platform'); // actions/elements has some dependencies on ui/new_platform.
jest.mock('../../../lib/app_state');

Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/canvas/scripts/_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
const { resolve } = require('path');

exports.runGulpTask = function(name) {
process.chdir(resolve(__dirname, '../../../..'));
process.chdir(resolve(__dirname, '../../..'));
process.argv.splice(1, 1, require.resolve('gulp/bin/gulp'), name);
require('gulp/bin/gulp');
};

exports.runKibanaScript = function(name, args = []) {
process.chdir(resolve(__dirname, '../../../../..'));
process.chdir(resolve(__dirname, '../../../..'));
process.argv.splice(2, 0, ...args);
require('../../../../../scripts/' + name); // eslint-disable-line import/no-dynamic-require
require('../../../../scripts/' + name); // eslint-disable-line import/no-dynamic-require
};

exports.runXPackScript = function(name, args = []) {
process.chdir(resolve(__dirname, '../../../..'));
process.chdir(resolve(__dirname, '../../..'));
process.argv.splice(2, 0, ...args);
require('../../../../scripts/' + name); // eslint-disable-line import/no-dynamic-require
require('../../../scripts/' + name); // eslint-disable-line import/no-dynamic-require
};

0 comments on commit 2dab77b

Please sign in to comment.