mirror of
https://github.com/grafana/grafana.git
synced 2024-11-28 03:34:15 -06:00
0598d60234
* Chore: Adds throwUnhandledRejections to jest setup * Bring back @grafana/runtime import * Fix broken metric metadata aggregation test
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { configure } from 'enzyme';
|
|
import Adapter from 'enzyme-adapter-react-16';
|
|
import 'jquery';
|
|
import $ from 'jquery';
|
|
import 'angular';
|
|
import angular from 'angular';
|
|
|
|
angular.module('grafana', ['ngRoute']);
|
|
angular.module('grafana.services', ['ngRoute', '$strap.directives']);
|
|
angular.module('grafana.panels', []);
|
|
angular.module('grafana.controllers', []);
|
|
angular.module('grafana.directives', []);
|
|
angular.module('grafana.filters', []);
|
|
angular.module('grafana.routes', ['ngRoute']);
|
|
|
|
jest.mock('app/core/core', () => ({}));
|
|
jest.mock('app/features/plugins/plugin_loader', () => ({}));
|
|
|
|
configure({ adapter: new Adapter() });
|
|
|
|
const global = window as any;
|
|
global.$ = global.jQuery = $;
|
|
|
|
const localStorageMock = (() => {
|
|
let store: any = {};
|
|
return {
|
|
getItem: (key: string) => {
|
|
return store[key];
|
|
},
|
|
setItem: (key: string, value: any) => {
|
|
store[key] = value.toString();
|
|
},
|
|
clear: () => {
|
|
store = {};
|
|
},
|
|
removeItem: (key: string) => {
|
|
delete store[key];
|
|
},
|
|
};
|
|
})();
|
|
|
|
global.localStorage = localStorageMock;
|
|
// Object.defineProperty(window, 'localStorage', { value: localStorageMock });
|
|
|
|
const throwUnhandledRejections = () => {
|
|
process.on('unhandledRejection', err => {
|
|
throw err;
|
|
});
|
|
};
|
|
|
|
throwUnhandledRejections();
|