mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[APM] Fix broken unit tests (#161636)
A bunch of APM unit tests were passing on CI but failing locally. This
PR fixes the unit tests
**Why fail locally and pass on CI??**
The reason they pass on CI is because `console.error` calls are omitted.
In the APM jest config `console.error` is treated as a test failure:
7ea0dd6b11/x-pack/plugins/apm/jest_setup.js (L12-L15)
This commit is contained in:
parent
3a434bfe85
commit
ccb36d929a
3 changed files with 17 additions and 11 deletions
|
@ -10,6 +10,7 @@ import React, { useState } from 'react';
|
|||
import { CoreStart } from '@kbn/core/public';
|
||||
import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public';
|
||||
import { TIME_UNITS } from '@kbn/triggers-actions-ui-plugin/public';
|
||||
import { __IntlProvider as IntlProvider } from '@kbn/i18n-react';
|
||||
import { RuleParams, ErrorCountRuleType } from '.';
|
||||
import { ENVIRONMENT_ALL } from '../../../../../common/environment_filter_values';
|
||||
import { createCallApmApi } from '../../../../services/rest/create_call_apm_api';
|
||||
|
@ -36,11 +37,13 @@ const stories: Meta<{}> = {
|
|||
createCallApmApi(coreMock);
|
||||
|
||||
return (
|
||||
<KibanaReactContext.Provider>
|
||||
<div style={{ width: 400 }}>
|
||||
<StoryComponent />
|
||||
</div>
|
||||
</KibanaReactContext.Provider>
|
||||
<IntlProvider locale="en">
|
||||
<KibanaReactContext.Provider>
|
||||
<div style={{ width: 400 }}>
|
||||
<StoryComponent />
|
||||
</div>
|
||||
</KibanaReactContext.Provider>
|
||||
</IntlProvider>
|
||||
);
|
||||
},
|
||||
],
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { render } from '@testing-library/react';
|
||||
import { createMemoryHistory } from 'history';
|
||||
import { createMemoryHistory, MemoryHistory } from 'history';
|
||||
import { CoreStart } from '@kbn/core/public';
|
||||
import React, { ReactNode } from 'react';
|
||||
import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public';
|
||||
|
@ -18,7 +18,7 @@ import * as useFetcherModule from '../../../hooks/use_fetcher';
|
|||
import { ServiceMap } from '.';
|
||||
import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values';
|
||||
|
||||
const history = createMemoryHistory();
|
||||
let history: MemoryHistory<unknown>;
|
||||
|
||||
const KibanaReactContext = createKibanaReactContext({
|
||||
usageCollection: { reportUiCounter: () => {} },
|
||||
|
@ -47,6 +47,7 @@ const expiredLicense = new License({
|
|||
});
|
||||
|
||||
function createWrapper(license: License | null) {
|
||||
history = createMemoryHistory();
|
||||
history.replace('/service-map?rangeFrom=now-15m&rangeTo=now');
|
||||
|
||||
return ({ children }: { children?: ReactNode }) => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { queryByLabelText } from '@testing-library/react';
|
||||
import { createMemoryHistory } from 'history';
|
||||
import { createMemoryHistory, MemoryHistory } from 'history';
|
||||
import { CoreStart } from '@kbn/core/public';
|
||||
import React from 'react';
|
||||
import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public';
|
||||
|
@ -32,9 +32,7 @@ const KibanaReactContext = createKibanaReactContext({
|
|||
usageCollection: { reportUiCounter: () => {} },
|
||||
} as unknown as Partial<CoreStart>);
|
||||
|
||||
const history = createMemoryHistory();
|
||||
jest.spyOn(history, 'push');
|
||||
jest.spyOn(history, 'replace');
|
||||
let history: MemoryHistory<unknown>;
|
||||
|
||||
function setup({
|
||||
urlParams,
|
||||
|
@ -43,6 +41,10 @@ function setup({
|
|||
urlParams: ApmUrlParams;
|
||||
serviceTransactionTypes: string[];
|
||||
}) {
|
||||
history = createMemoryHistory();
|
||||
jest.spyOn(history, 'push');
|
||||
jest.spyOn(history, 'replace');
|
||||
|
||||
history.replace({
|
||||
pathname: '/services/foo/transactions',
|
||||
search: fromQuery(urlParams),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue