mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Fix a couple more console errors in jest tests (#46732)
* Chore: Fix a couple more console errors in jest tests * remove console.errors * better spy * Fix linting
This commit is contained in:
@@ -183,6 +183,15 @@ describe('graphiteDatasource', () => {
|
||||
|
||||
describe('when fetching Graphite Events as annotations', () => {
|
||||
let results: any;
|
||||
let errorSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
errorSpy = jest.spyOn(console, 'error').mockImplementation();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
errorSpy.mockRestore();
|
||||
});
|
||||
|
||||
const options = {
|
||||
annotation: {
|
||||
@@ -260,6 +269,7 @@ describe('graphiteDatasource', () => {
|
||||
results = data;
|
||||
});
|
||||
expect(results).toEqual([]);
|
||||
expect(console.error).toHaveBeenCalledWith(expect.stringMatching(/Unable to get annotations/));
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { dispatch } from 'app/store/store';
|
||||
import gfunc from '../gfunc';
|
||||
import { TemplateSrvStub } from 'test/specs/helpers';
|
||||
import { silenceConsoleOutput } from 'test/core/utils/silenceConsoleOutput';
|
||||
import { actions } from '../state/actions';
|
||||
import {
|
||||
getAltSegmentsSelectables,
|
||||
@@ -236,7 +235,6 @@ describe('Graphite actions', () => {
|
||||
});
|
||||
|
||||
describe('when autocomplete for metric names is not available', () => {
|
||||
silenceConsoleOutput();
|
||||
beforeEach(() => {
|
||||
ctx.state.datasource.getTagsAutoComplete = jest.fn().mockReturnValue(Promise.resolve([]));
|
||||
ctx.state.datasource.metricFindQuery = jest.fn().mockReturnValue(
|
||||
@@ -267,7 +265,6 @@ describe('Graphite actions', () => {
|
||||
});
|
||||
|
||||
describe('when autocomplete for tags is not available', () => {
|
||||
silenceConsoleOutput();
|
||||
beforeEach(() => {
|
||||
ctx.datasource.metricFindQuery = jest.fn().mockReturnValue(Promise.resolve([]));
|
||||
ctx.datasource.getTagsAutoComplete = jest.fn().mockReturnValue(
|
||||
|
@@ -172,7 +172,6 @@ export function handleMetricsAutoCompleteError(
|
||||
state: GraphiteQueryEditorState,
|
||||
error: Error
|
||||
): GraphiteQueryEditorState {
|
||||
console.error(error);
|
||||
if (!state.metricAutoCompleteErrorShown) {
|
||||
state.metricAutoCompleteErrorShown = true;
|
||||
dispatch(notifyApp(createErrorNotification(`Fetching metrics failed: ${error.message}.`)));
|
||||
@@ -184,7 +183,6 @@ export function handleMetricsAutoCompleteError(
|
||||
* When tags autocomplete fails - the error is shown, but only once per page view
|
||||
*/
|
||||
export function handleTagsAutoCompleteError(state: GraphiteQueryEditorState, error: Error): GraphiteQueryEditorState {
|
||||
console.error(error);
|
||||
if (!state.tagsAutoCompleteErrorShown) {
|
||||
state.tagsAutoCompleteErrorShown = true;
|
||||
dispatch(notifyApp(createErrorNotification(`Fetching tags failed: ${error.message}.`)));
|
||||
|
Reference in New Issue
Block a user