From dfe9cb14264e9baa904de379eae51429ce7ca80a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Wed, 3 Apr 2019 14:16:23 -0700 Subject: [PATCH] fix(tests): mock fetch for LabelValueInput tests Gettings lots of nodejs warnings about unhandled fetch errors due to lack of mocks for suggestion fetch requests, add mocks to supress those --- .../SilenceModal/SilenceMatch/LabelValueInput.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.test.js b/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.test.js index 9b2c095b9..00a529816 100644 --- a/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.test.js +++ b/ui/src/Components/SilenceModal/SilenceMatch/LabelValueInput.test.js @@ -14,6 +14,10 @@ import { LabelValueInput } from "./LabelValueInput"; let silenceFormStore; let matcher; +beforeAll(() => { + fetch.mockResponse(JSON.stringify([])); +}); + beforeEach(() => { silenceFormStore = new SilenceFormStore(); matcher = NewEmptyMatcher(); @@ -28,6 +32,10 @@ beforeEach(() => { ]; }); +afterEach(() => { + jest.restoreAllMocks(); +}); + const ShallowLabelValueInput = isValid => { return shallow(