Skip to content

Commit

Permalink
updated jest tests to avoid generating unhandled promise rejections
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Sep 22, 2021
1 parent 1fb0982 commit 78c031b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { SearchSource, SearchSourceDependencies, SortDirection } from './';
import { AggConfigs, AggTypesRegistryStart } from '../../';
import { mockAggTypesRegistry } from '../aggs/test_helpers';
import { RequestResponder } from 'src/plugins/inspector/common';
import { switchMap } from 'rxjs/operators';
import { switchMap, catchError } from 'rxjs/operators';
import { Filter } from '@kbn/es-query';

const getComputedFields = () => ({
Expand Down Expand Up @@ -1117,8 +1117,10 @@ describe('SearchSource', () => {

searchSource = new SearchSource({}, searchSourceDependencies);
searchSource.setField('index', indexPattern);

await searchSource
.fetch$(options)
.pipe(catchError((e) => e))
.toPromise()
.catch(() => {});

Expand Down
4 changes: 1 addition & 3 deletions src/plugins/data/server/search/search_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ describe('Search service', () => {
let mockCoreStart: MockedKeys<CoreStart>;

beforeEach(() => {
const mockLogger: any = {
debug: () => {},
};
const context = coreMock.createPluginInitializerContext({});
const mockLogger = context.logger.get();
context.config.create = jest.fn().mockImplementation(() => {
return of({
search: {
Expand Down

0 comments on commit 78c031b

Please sign in to comment.