From 2f857acbb75f36a97dd39c1ebe56289ccd1a55d3 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Wed, 29 Dec 2021 11:08:54 -0600 Subject: [PATCH] utils/monkey-patch: remove try/catch in test The try/catch would also suppress the fail() which would make the test always succeed even when it should fail. Jest has a .rejects API that can be used instead. --- src/utils/monkey-patch.test.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/utils/monkey-patch.test.tsx b/src/utils/monkey-patch.test.tsx index 4386a32c..3df61f27 100644 --- a/src/utils/monkey-patch.test.tsx +++ b/src/utils/monkey-patch.test.tsx @@ -65,12 +65,9 @@ it.each([false, true])( await waitForElementToBeRemoved(screen.getByText(testTooltipText)); } else { // if the patch was not applied, the bug should be triggered - try { - await waitForElementToBeRemoved(screen.getByText(testTooltipText)); - fail('bug was not triggered'); - } catch (err) { - // error was expected - } + await expect( + waitForElementToBeRemoved(screen.getByText(testTooltipText)), + ).rejects.toBeInstanceOf(Error); } }, );