[Visualize] [Lens] remove warning and logs from console when testing (#113070)
* date_ranges console.warn removed * lens app console info remved * percentailize i18n & generate id removed * vega_parser.test canvas mock warning removed * vega console logs removed from tests Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
2fd7f85877
commit
cfe084829f
|
@ -55,6 +55,9 @@ describe('DateRangesParamEditor component', () => {
|
|||
});
|
||||
|
||||
it('should validate range values with date math', function () {
|
||||
const mockedConsoleWarn = jest.spyOn(console, 'warn'); // mocked console.warn to avoid console messages when running tests
|
||||
mockedConsoleWarn.mockImplementation(() => {});
|
||||
|
||||
const component = mountWithIntl(<DateRangesWrapped {...defaultProps} />);
|
||||
|
||||
// should allow empty values
|
||||
|
@ -86,5 +89,7 @@ describe('DateRangesParamEditor component', () => {
|
|||
|
||||
component.setProps({ value: [{ from: '5/5/2005+3d' }] });
|
||||
expect(setValidity).toHaveBeenNthCalledWith(10, false);
|
||||
|
||||
mockedConsoleWarn.mockRestore();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,10 +9,22 @@
|
|||
import React from 'react';
|
||||
import { AggParamEditorProps } from '../agg_param_props';
|
||||
import { IAggConfig } from 'src/plugins/data/public';
|
||||
import { mount } from 'enzyme';
|
||||
import { mountWithIntl as mount } from '@kbn/test/jest';
|
||||
import { PercentilesEditor } from './percentiles';
|
||||
import { EditorVisState } from '../sidebar/state/reducers';
|
||||
|
||||
// mocking random id generator function
|
||||
jest.mock('@elastic/eui', () => {
|
||||
const original = jest.requireActual('@elastic/eui');
|
||||
|
||||
return {
|
||||
...original,
|
||||
htmlIdGenerator: (fn: unknown) => {
|
||||
let counter = 0;
|
||||
return () => counter++;
|
||||
},
|
||||
};
|
||||
});
|
||||
describe('PercentilesEditor component', () => {
|
||||
let setValue: jest.Mock;
|
||||
let setValidity: jest.Mock;
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { cloneDeep } from 'lodash';
|
||||
import 'jest-canvas-mock';
|
||||
import { euiThemeVars } from '@kbn/ui-shared-deps-src/theme';
|
||||
import { VegaParser } from './vega_parser';
|
||||
import { bypassExternalUrlCheck } from '../vega_view/vega_base_view';
|
||||
|
|
|
@ -124,6 +124,8 @@ describe('vega_map_view/view', () => {
|
|||
} as unknown as VegaViewParams);
|
||||
}
|
||||
|
||||
let mockedConsoleLog: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
vegaParser = new VegaParser(
|
||||
JSON.stringify(vegaMap),
|
||||
|
@ -137,10 +139,13 @@ describe('vega_map_view/view', () => {
|
|||
{},
|
||||
mockGetServiceSettings
|
||||
);
|
||||
mockedConsoleLog = jest.spyOn(console, 'log'); // mocked console.log to avoid messages in the console when running tests
|
||||
mockedConsoleLog.mockImplementation(() => {}); // comment this line when console logging for debugging
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
mockedConsoleLog.mockRestore();
|
||||
});
|
||||
|
||||
test('should be added TmsRasterLayer and do not use tmsService if mapStyle is "user_configured"', async () => {
|
||||
|
|
|
@ -81,7 +81,11 @@ describe('VegaVisualizations', () => {
|
|||
mockWidth.mockRestore();
|
||||
mockHeight.mockRestore();
|
||||
});
|
||||
|
||||
test('should show vegalite graph and update on resize (may fail in dev env)', async () => {
|
||||
const mockedConsoleLog = jest.spyOn(console, 'log'); // mocked console.log to avoid messages in the console when running tests
|
||||
mockedConsoleLog.mockImplementation(() => {}); // comment this line when console logging for debugging comment this line
|
||||
|
||||
let vegaVis;
|
||||
try {
|
||||
vegaVis = new VegaVisualization(domNode, jest.fn());
|
||||
|
@ -111,6 +115,8 @@ describe('VegaVisualizations', () => {
|
|||
} finally {
|
||||
vegaVis.destroy();
|
||||
}
|
||||
expect(console.log).toBeCalledTimes(2);
|
||||
mockedConsoleLog.mockRestore();
|
||||
});
|
||||
|
||||
test('should show vega graph (may fail in dev env)', async () => {
|
||||
|
@ -130,7 +136,6 @@ describe('VegaVisualizations', () => {
|
|||
mockGetServiceSettings
|
||||
);
|
||||
await vegaParser.parseAsync();
|
||||
|
||||
await vegaVis.render(vegaParser);
|
||||
expect(domNode.innerHTML).toMatchSnapshot();
|
||||
} finally {
|
||||
|
|
|
@ -604,6 +604,9 @@ describe('Lens App', () => {
|
|||
});
|
||||
|
||||
it('handles save failure by showing a warning, but still allows another save', async () => {
|
||||
const mockedConsoleDir = jest.spyOn(console, 'dir'); // mocked console.dir to avoid messages in the console when running tests
|
||||
mockedConsoleDir.mockImplementation(() => {});
|
||||
|
||||
const services = makeDefaultServices(sessionIdSubject);
|
||||
services.attributeService.wrapAttributes = jest
|
||||
.fn()
|
||||
|
@ -620,6 +623,9 @@ describe('Lens App', () => {
|
|||
});
|
||||
expect(props.redirectTo).not.toHaveBeenCalled();
|
||||
expect(getButton(instance).disableButton).toEqual(false);
|
||||
// eslint-disable-next-line no-console
|
||||
expect(console.dir).toHaveBeenCalledTimes(1);
|
||||
mockedConsoleDir.mockRestore();
|
||||
});
|
||||
|
||||
it('saves new doc and redirects to originating app', async () => {
|
||||
|
|
Loading…
Reference in a new issue