import Enzyme from "enzyme";
import Adapter from "enzyme-adapter-react-16";

// https://github.com/airbnb/enzyme
Enzyme.configure({ adapter: new Adapter() });

// favico.js needs canvas
import("jest-canvas-mock");

// used to mock current time since we render moment.fromNow() in some places
import("jest-date-mock");

// fetch is used in multiple places to interact with Go backend
// or upstream Alertmanager API
global.fetch = require("jest-fetch-mock");

// ensure that all console messages throw errors
for (const level of ["error", "warn", "info", "log", "trace"]) {
  global.console[level] = (message, ...args) => {
    throw new Error(`message=${message} args=${args}`);
  };
}
