diff --git a/ui/src/AppBoot.test.js b/ui/src/AppBoot.test.js
index f3da8bc1b..16f8a7866 100644
--- a/ui/src/AppBoot.test.js
+++ b/ui/src/AppBoot.test.js
@@ -2,6 +2,14 @@ import * as Sentry from "@sentry/browser";
import { SettingsElement, SetupSentry, ParseDefaultFilters } from "./AppBoot";
+beforeAll(() => {
+ // https://github.com/jamesmfriedman/rmwc/issues/103#issuecomment-360007979
+ Object.defineProperty(window.HTMLElement.prototype, "dataset", {
+ writable: true,
+ value: {}
+ });
+});
+
afterEach(() => {
// reset sentry state before each mock, that's the only way to revert
// Sentry.init() that I found
diff --git a/ui/src/Components/Grid/AlertGrid/AlertGroup/Alert/__snapshots__/index.test.js.snap b/ui/src/Components/Grid/AlertGrid/AlertGroup/Alert/__snapshots__/index.test.js.snap
index d2bcd90db..82930fa36 100644
--- a/ui/src/Components/Grid/AlertGrid/AlertGroup/Alert/__snapshots__/index.test.js.snap
+++ b/ui/src/Components/Grid/AlertGrid/AlertGroup/Alert/__snapshots__/index.test.js.snap
@@ -52,6 +52,7 @@ exports[` matches snapshot with showAlertmanagers=false showReceiver=fa
role=\\"img\\"
xmlns=\\"http://www.w3.org/2000/svg\\"
viewbox=\\"0 0 320 512\\"
+ style=\\"width: 0.8rem;\\"
>
", () => {
});
it("calls window.location.reload after timer is done", () => {
- const reloadSpy = jest.spyOn(global.window.location, "reload");
+ const reloadSpy = jest
+ .spyOn(global.window.location, "reload")
+ .mockImplementation(() => {});
mount();
jest.runOnlyPendingTimers();
expect(reloadSpy).toBeCalled();
diff --git a/ui/src/ErrorBoundary.test.js b/ui/src/ErrorBoundary.test.js
index f7b87412c..22ab56150 100644
--- a/ui/src/ErrorBoundary.test.js
+++ b/ui/src/ErrorBoundary.test.js
@@ -30,8 +30,12 @@ const MountedFailingComponent = () => {
describe("", () => {
it("matches snapshot", () => {
+ const consoleSpy = jest
+ .spyOn(console, "error")
+ .mockImplementation(() => {});
const tree = MountedFailingComponent();
expect(toDiffableHtml(tree.html())).toMatchSnapshot();
+ expect(consoleSpy).toHaveBeenCalled();
});
it("componentDidCatch should catch an error from FailingComponent", () => {
diff --git a/ui/src/setupTests.js b/ui/src/setupTests.js
index 5ed478deb..276cd1343 100644
--- a/ui/src/setupTests.js
+++ b/ui/src/setupTests.js
@@ -5,13 +5,13 @@ import Adapter from "enzyme-adapter-react-16";
Enzyme.configure({ adapter: new Adapter() });
// localStorage is used for Settings store
-require("jest-localstorage-mock");
+import("jest-localstorage-mock");
// favico.js needs canvas
-require("jest-canvas-mock");
+import("jest-canvas-mock");
// used to mock current time since we render moment.fromNow() in some places
-require("jest-date-mock");
+import("jest-date-mock");
// fetch is used in multiple places to interact with Go backend
// or upstream Alertmanager API