mirror of
https://github.com/prymitive/karma
synced 2026-05-09 03:36:44 +00:00
There's a lot of 3rd party components using deprecated methods so there's a lot of warnings, and currently this is failing all tests. Ignore these for now as we need to wait for components to be fixed
27 lines
993 B
JavaScript
27 lines
993 B
JavaScript
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"]) {
|
|
// https://reactjs.org/blog/2019/08/08/react-v16.9.0.html#new-deprecations
|
|
const reactDeprecationWarning = /.*has been renamed, and is not recommended for use\. See https:\/\/fb.me\/react-async-component-lifecycle-hooks for details.*/;
|
|
global.console[level] = (message, ...args) => {
|
|
if (reactDeprecationWarning.test(message) === false) {
|
|
throw new Error(`message=${message} args=${args}`);
|
|
}
|
|
};
|
|
}
|