From 8eedb5710415be7bdc72791a526fe0e656453bab Mon Sep 17 00:00:00 2001 From: Dorian Karter Date: Sun, 10 Apr 2022 00:13:00 -0500 Subject: [PATCH] Fix snapshot tests Previously all snapshots captured was a string representation of a function (`[Function]`). This made the tests useless because the result would always be a Function no matter what and so they will always pass, even if material changes happened. --- src/test/__snapshots__/app.spec.tsx.snap | 6 +- src/test/app.spec.tsx | 4 +- .../__snapshots__/app.spec.tsx.snap | 107 +- .../__snapshots__/appCategory.spec.tsx.snap | 84 +- .../__snapshots__/appList.spec.tsx.snap | 294 ++- .../__snapshots__/apps.spec.tsx.snap | 2006 ++++++++++++++++- .../__snapshots__/bookmarks.spec.tsx.snap | 125 +- .../__snapshots__/greeter.spec.tsx.snap | 27 +- .../__snapshots__/icon.spec.tsx.snap | 41 +- .../__snapshots__/imprint.spec.tsx.snap | 121 +- .../__snapshots__/modal.spec.tsx.snap | 194 +- .../__snapshots__/searchBar.spec.tsx.snap | 40 +- .../__snapshots__/select.spec.tsx.snap | 113 +- .../__snapshots__/settings.spec.tsx.snap | 1463 +++++++++++- src/test/components/app.spec.tsx | 12 +- src/test/components/appCategory.spec.tsx | 4 +- src/test/components/appList.spec.tsx | 16 +- src/test/components/apps.spec.tsx | 16 +- src/test/components/bookmarks.spec.tsx | 20 +- src/test/components/greeter.spec.tsx | 8 +- src/test/components/icon.spec.tsx | 10 +- src/test/components/imprint.spec.tsx | 8 +- src/test/components/modal.spec.tsx | 10 +- src/test/components/searchBar.spec.tsx | 4 +- src/test/components/select.spec.tsx | 16 +- src/test/components/settings.spec.tsx | 16 +- 26 files changed, 4645 insertions(+), 120 deletions(-) diff --git a/src/test/__snapshots__/app.spec.tsx.snap b/src/test/__snapshots__/app.spec.tsx.snap index 7934f40..175edc6 100644 --- a/src/test/__snapshots__/app.spec.tsx.snap +++ b/src/test/__snapshots__/app.spec.tsx.snap @@ -1,3 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`app.tsx Tests GlobalStyle 1`] = `[Function]`; +exports[`app.tsx Tests GlobalStyle 1`] = ` + +
+ +`; diff --git a/src/test/app.spec.tsx b/src/test/app.spec.tsx index 50ac1e3..4c9ba14 100644 --- a/src/test/app.spec.tsx +++ b/src/test/app.spec.tsx @@ -12,7 +12,7 @@ const props: IThemeProps = { describe("app.tsx", () => { it("Tests GlobalStyle", () => { - const { asFragment } = render(); - expect(asFragment).toMatchSnapshot(); + const { baseElement } = render(); + expect(baseElement).toMatchSnapshot(); }); }); diff --git a/src/test/components/__snapshots__/app.spec.tsx.snap b/src/test/components/__snapshots__/app.spec.tsx.snap index 7ffd871..156633e 100644 --- a/src/test/components/__snapshots__/app.spec.tsx.snap +++ b/src/test/components/__snapshots__/app.spec.tsx.snap @@ -1,7 +1,108 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`app.tsx Tests app rendering with newTab=false 1`] = `[Function]`; +exports[`app.tsx Tests app rendering with newTab=false 1`] = ` + +
+ +
+ + bug_report + +
+
+
+ App Test +
+

+ test +

+
+
+
+ +`; -exports[`app.tsx Tests app rendering with newTab=true 1`] = `[Function]`; +exports[`app.tsx Tests app rendering with newTab=true 1`] = ` + +
+ +
+ + bug_report + +
+
+
+ App Test +
+

+ test +

+
+
+
+ +`; -exports[`app.tsx Tests app rendering without newTab 1`] = `[Function]`; +exports[`app.tsx Tests app rendering without newTab 1`] = ` + +
+ +
+ + bug_report + +
+
+
+ App Test +
+

+ test +

+
+
+
+ +`; diff --git a/src/test/components/__snapshots__/appCategory.spec.tsx.snap b/src/test/components/__snapshots__/appCategory.spec.tsx.snap index 0b26ca0..4da91c5 100644 --- a/src/test/components/__snapshots__/appCategory.spec.tsx.snap +++ b/src/test/components/__snapshots__/appCategory.spec.tsx.snap @@ -1,3 +1,85 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AppCategory snapshot test 1`] = `[Function]`; +exports[`AppCategory snapshot test 1`] = ` + +
+ +
+ +`; diff --git a/src/test/components/__snapshots__/appList.spec.tsx.snap b/src/test/components/__snapshots__/appList.spec.tsx.snap index 9535b28..df0ae0b 100644 --- a/src/test/components/__snapshots__/appList.spec.tsx.snap +++ b/src/test/components/__snapshots__/appList.spec.tsx.snap @@ -1,9 +1,295 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`appList.tsx Tests AppList rendering with apps 1`] = `[Function]`; +exports[`appList.tsx Tests AppList rendering with apps 1`] = ` + +
+
+

+ Applications +

+ +
+
+ +`; -exports[`appList.tsx Tests AppList rendering with categories 1`] = `[Function]`; +exports[`appList.tsx Tests AppList rendering with categories 1`] = ` + +
+ +
+ +`; -exports[`appList.tsx Tests AppList rendering with categories and apps 1`] = `[Function]`; +exports[`appList.tsx Tests AppList rendering with categories and apps 1`] = ` + +
+ +
+ +`; -exports[`appList.tsx Tests AppList rendering with neither 1`] = `[Function]`; +exports[`appList.tsx Tests AppList rendering with neither 1`] = ` + +
+ +`; diff --git a/src/test/components/__snapshots__/apps.spec.tsx.snap b/src/test/components/__snapshots__/apps.spec.tsx.snap index bccc6d6..2ee79c1 100644 --- a/src/test/components/__snapshots__/apps.spec.tsx.snap +++ b/src/test/components/__snapshots__/apps.spec.tsx.snap @@ -1,19 +1,2007 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`app.tsx Tests App rendering with newTab 1`] = `[Function]`; +exports[`app.tsx Tests App rendering with newTab 1`] = ` + + + +`; -exports[`app.tsx Tests App rendering with newTab 2`] = `[Function]`; +exports[`app.tsx Tests App rendering with newTab 2`] = ` + + + + +`; -exports[`app.tsx Tests App rendering without newTab 1`] = `[Function]`; +exports[`app.tsx Tests App rendering without newTab 1`] = ` + + + +`; -exports[`app.tsx Tests AppCategory rendering 1`] = `[Function]`; +exports[`app.tsx Tests AppCategory rendering 1`] = ` + + + +`; -exports[`app.tsx Tests AppCategory rendering 2`] = `[Function]`; +exports[`app.tsx Tests AppCategory rendering 2`] = ` + + + + +`; -exports[`app.tsx Tests AppList rendering 1`] = `[Function]`; +exports[`app.tsx Tests AppList rendering 1`] = ` + + + +`; -exports[`app.tsx Tests AppList rendering 2`] = `[Function]`; +exports[`app.tsx Tests AppList rendering 2`] = ` + + + + +`; -exports[`app.tsx Tests AppList rendering 3`] = `[Function]`; +exports[`app.tsx Tests AppList rendering 3`] = ` + + + + + +`; -exports[`app.tsx Tests AppList rendering 4`] = `[Function]`; +exports[`app.tsx Tests AppList rendering 4`] = ` + + + + +
+ +`; diff --git a/src/test/components/__snapshots__/bookmarks.spec.tsx.snap b/src/test/components/__snapshots__/bookmarks.spec.tsx.snap index bdab497..aa93a64 100644 --- a/src/test/components/__snapshots__/bookmarks.spec.tsx.snap +++ b/src/test/components/__snapshots__/bookmarks.spec.tsx.snap @@ -1,11 +1,126 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`tests rendering of Bookmark with newTab=false 1`] = `[Function]`; +exports[`tests rendering of Bookmark with newTab=false 1`] = ` + + + +`; -exports[`tests rendering of Bookmark with newTab=true 1`] = `[Function]`; +exports[`tests rendering of Bookmark with newTab=true 1`] = ` + + + +`; -exports[`tests rendering of Bookmark without newTab 1`] = `[Function]`; +exports[`tests rendering of Bookmark without newTab 1`] = ` + + + +`; -exports[`tests rendering of BookmarkGroup 1`] = `[Function]`; +exports[`tests rendering of BookmarkGroup 1`] = ` + +
+
  • +
    +

    + Test Group +

    + + Bookmark Test + +
    +
  • +
    + +`; -exports[`tests rendering of BookmarkList 1`] = `[Function]`; +exports[`tests rendering of BookmarkList 1`] = ` + +
    +
    +

    + Bookmarks +

    + +
    +
    + +`; diff --git a/src/test/components/__snapshots__/greeter.spec.tsx.snap b/src/test/components/__snapshots__/greeter.spec.tsx.snap index 09f6c9f..1d78908 100644 --- a/src/test/components/__snapshots__/greeter.spec.tsx.snap +++ b/src/test/components/__snapshots__/greeter.spec.tsx.snap @@ -1,5 +1,28 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Greeter snapshot test with properties 1`] = `[Function]`; +exports[`Greeter snapshot test with properties 1`] = ` + +
    +
    +

    + Sunday, April 10th 2022 +

    +

    + Good night! +

    +
    +
    + +`; -exports[`Greeter snapshot test without properties 1`] = `[Function]`; +exports[`Greeter snapshot test without properties 1`] = ` + +
    + +`; diff --git a/src/test/components/__snapshots__/icon.spec.tsx.snap b/src/test/components/__snapshots__/icon.spec.tsx.snap index 6de0c03..284526d 100644 --- a/src/test/components/__snapshots__/icon.spec.tsx.snap +++ b/src/test/components/__snapshots__/icon.spec.tsx.snap @@ -1,7 +1,42 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Icon test (no size) 1`] = `[Function]`; +exports[`Icon test (no size) 1`] = ` + +
    + + bug_report + +
    + +`; -exports[`Icon test 1`] = `[Function]`; +exports[`Icon test 1`] = ` + +
    + + bug_report + +
    + +`; -exports[`IconButton test 1`] = `[Function]`; +exports[`IconButton test 1`] = ` + +
    + +
    + +`; diff --git a/src/test/components/__snapshots__/imprint.spec.tsx.snap b/src/test/components/__snapshots__/imprint.spec.tsx.snap index 1577f11..2d8b5c1 100644 --- a/src/test/components/__snapshots__/imprint.spec.tsx.snap +++ b/src/test/components/__snapshots__/imprint.spec.tsx.snap @@ -1,5 +1,122 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`imprint.tsx Tests Imprint 1`] = `[Function]`; +exports[`imprint.tsx Tests Imprint 1`] = ` + +
    +
    +

    + About +

    + +
    +
    + +`; -exports[`imprint.tsx Tests ImprintField 1`] = `[Function]`; +exports[`imprint.tsx Tests ImprintField 1`] = ` + + + +`; diff --git a/src/test/components/__snapshots__/modal.spec.tsx.snap b/src/test/components/__snapshots__/modal.spec.tsx.snap index aebd894..1678aa2 100644 --- a/src/test/components/__snapshots__/modal.spec.tsx.snap +++ b/src/test/components/__snapshots__/modal.spec.tsx.snap @@ -1,11 +1,195 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`modal.tsx Tests modal with icon 1`] = `[Function]`; +exports[`modal.tsx Tests modal with icon 1`] = ` + +
    + + +
    + +`; -exports[`modal.tsx Tests modal with icon button 1`] = `[Function]`; +exports[`modal.tsx Tests modal with icon button 1`] = ` + +
    + + +
    + +`; -exports[`modal.tsx Tests modal with neither 1`] = `[Function]`; +exports[`modal.tsx Tests modal with neither 1`] = ` + +
    + +
    + +`; -exports[`modal.tsx Tests modal with text button 1`] = `[Function]`; +exports[`modal.tsx Tests modal with text button 1`] = ` + +
    + +

    + Test +

    +
    + +`; -exports[`modal.tsx Tests modal without onClose behaviour 1`] = `[Function]`; +exports[`modal.tsx Tests modal without onClose behaviour 1`] = ` + +
    + +
    + +`; diff --git a/src/test/components/__snapshots__/searchBar.spec.tsx.snap b/src/test/components/__snapshots__/searchBar.spec.tsx.snap index 0203d30..c34ca48 100644 --- a/src/test/components/__snapshots__/searchBar.spec.tsx.snap +++ b/src/test/components/__snapshots__/searchBar.spec.tsx.snap @@ -1,5 +1,41 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`searchBar.tsx Tests SearchBar rendering with properties 1`] = `[Function]`; +exports[`searchBar.tsx Tests SearchBar rendering with properties 1`] = ` + +
    +
    + + + +
    +
    + +`; -exports[`searchBar.tsx Tests searchBar rendering without properties 1`] = `[Function]`; +exports[`searchBar.tsx Tests searchBar rendering without properties 1`] = ` + +
    + +`; diff --git a/src/test/components/__snapshots__/select.spec.tsx.snap b/src/test/components/__snapshots__/select.spec.tsx.snap index 1441de6..a4fdbbf 100644 --- a/src/test/components/__snapshots__/select.spec.tsx.snap +++ b/src/test/components/__snapshots__/select.spec.tsx.snap @@ -1,9 +1,114 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`select.tsx Tests \`current\`-value with testId 1`] = `[Function]`; +exports[`select.tsx Tests \`current\`-value with testId 1`] = ` + +
    + +
    + +`; -exports[`select.tsx Tests \`current\`-value without testId 1`] = `[Function]`; +exports[`select.tsx Tests \`current\`-value without testId 1`] = ` + +
    + +
    + +`; -exports[`select.tsx Tests Select rendering 1`] = `[Function]`; +exports[`select.tsx Tests Select rendering 1`] = ` + +
    + +
    + +`; -exports[`select.tsx Tests rendering of multiple Select elements 1`] = `[Function]`; +exports[`select.tsx Tests rendering of multiple Select elements 1`] = ` + +
    + + +
    + +`; diff --git a/src/test/components/__snapshots__/settings.spec.tsx.snap b/src/test/components/__snapshots__/settings.spec.tsx.snap index 4ef60fe..c903ad4 100644 --- a/src/test/components/__snapshots__/settings.spec.tsx.snap +++ b/src/test/components/__snapshots__/settings.spec.tsx.snap @@ -1,15 +1,1464 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`settings.tsx Tests forms 1`] = `[Function]`; +exports[`settings.tsx Tests forms 1`] = ` + +
    +
    +
    + +`; -exports[`settings.tsx Tests sections 1`] = `[Function]`; +exports[`settings.tsx Tests sections 1`] = ` + +
    +
    +

    + Test +

    +
    +
    + +`; -exports[`settings.tsx Tests settings rendering 1`] = `[Function]`; +exports[`settings.tsx Tests settings rendering 1`] = ` + +
    + + +
    + +`; -exports[`settings.tsx Tests settings rendering 2`] = `[Function]`; +exports[`settings.tsx Tests settings rendering 2`] = ` + +
    + + +
    +
    + + +
    + +`; -exports[`settings.tsx Tests settings rendering 3`] = `[Function]`; +exports[`settings.tsx Tests settings rendering 3`] = ` + +
    + + +
    +
    + + +
    +
    + + +
    + +`; -exports[`settings.tsx Tests settings rendering 4`] = `[Function]`; +exports[`settings.tsx Tests settings rendering 4`] = ` + +
    + + +
    +
    + + +
    +
    + + +
    +
    + +`; -exports[`settings.tsx Tests tables 1`] = `[Function]`; +exports[`settings.tsx Tests tables 1`] = ` + +
    + + + + + + + + + +
    + Test +
    + Test +
    +
    + +`; diff --git a/src/test/components/app.spec.tsx b/src/test/components/app.spec.tsx index bf7c2ba..b5ea5b7 100644 --- a/src/test/components/app.spec.tsx +++ b/src/test/components/app.spec.tsx @@ -10,7 +10,7 @@ const props: IAppProps = { describe("app.tsx", () => { it("Tests app rendering with newTab=true", () => { - const { asFragment } = render( + const { baseElement } = render( { />, ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); it("Tests app rendering with newTab=false", () => { - const { asFragment } = render( + const { baseElement } = render( { />, ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); it("Tests app rendering without newTab", () => { - const { asFragment } = render( + const { baseElement } = render( { />, ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); }); diff --git a/src/test/components/appCategory.spec.tsx b/src/test/components/appCategory.spec.tsx index 1990ad2..55f06a1 100644 --- a/src/test/components/appCategory.spec.tsx +++ b/src/test/components/appCategory.spec.tsx @@ -22,9 +22,9 @@ const props: IAppCategoryProps = { }; it("AppCategory snapshot test", () => { - const { asFragment } = render( + const { baseElement } = render( , ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); diff --git a/src/test/components/appList.spec.tsx b/src/test/components/appList.spec.tsx index 4c879b0..a4f9bd7 100644 --- a/src/test/components/appList.spec.tsx +++ b/src/test/components/appList.spec.tsx @@ -36,25 +36,25 @@ const props: IAppListProps = { describe("appList.tsx", () => { it("Tests AppList rendering with categories and apps", () => { - const { asFragment } = render( + const { baseElement } = render( , ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); it("Tests AppList rendering with categories", () => { - const { asFragment } = render(); - expect(asFragment).toMatchSnapshot(); + const { baseElement } = render(); + expect(baseElement).toMatchSnapshot(); }); it("Tests AppList rendering with apps", () => { - const { asFragment } = render(); - expect(asFragment).toMatchSnapshot(); + const { baseElement } = render(); + expect(baseElement).toMatchSnapshot(); }); it("Tests AppList rendering with neither", () => { - const { asFragment } = render(); - expect(asFragment).toMatchSnapshot(); + const { baseElement } = render(); + expect(baseElement).toMatchSnapshot(); }); }); diff --git a/src/test/components/apps.spec.tsx b/src/test/components/apps.spec.tsx index 235afa4..027cfe1 100644 --- a/src/test/components/apps.spec.tsx +++ b/src/test/components/apps.spec.tsx @@ -50,7 +50,7 @@ describe("app.tsx", () => { const tests = [true, false]; tests.forEach((test: boolean) => { - const { asFragment } = render( + const { baseElement } = render( { />, ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); }); it("Tests App rendering without newTab", () => { - const { asFragment } = render( + const { baseElement } = render( { />, ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); it("Tests AppCategory rendering", () => { appCategoryProps.forEach((appCategory) => { - const { asFragment } = render( + const { baseElement } = render( , ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); }); it("Tests AppList rendering", () => { appListProps.forEach((appList) => { - const { asFragment } = render( + const { baseElement } = render( , ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); }); }); diff --git a/src/test/components/bookmarks.spec.tsx b/src/test/components/bookmarks.spec.tsx index 82cc419..714a5b8 100644 --- a/src/test/components/bookmarks.spec.tsx +++ b/src/test/components/bookmarks.spec.tsx @@ -22,44 +22,44 @@ const bookmarkListProps: IBookmarkListProps = { it("tests rendering of Bookmark with newTab=true", () => { let props = bookmarkGroupProps.items[0]; - const { asFragment } = render( + const { baseElement } = render( , ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); it("tests rendering of Bookmark with newTab=false", () => { let props = bookmarkGroupProps.items[0]; - const { asFragment } = render( + const { baseElement } = render( , ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); it("tests rendering of Bookmark without newTab", () => { let props = bookmarkGroupProps.items[0]; - const { asFragment } = render(); + const { baseElement } = render(); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); it("tests rendering of BookmarkGroup", () => { - const { asFragment } = render( + const { baseElement } = render( , ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); it("tests rendering of BookmarkList", () => { - const { asFragment } = render( + const { baseElement } = render( , ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); diff --git a/src/test/components/greeter.spec.tsx b/src/test/components/greeter.spec.tsx index a2adcfe..e1cad3f 100644 --- a/src/test/components/greeter.spec.tsx +++ b/src/test/components/greeter.spec.tsx @@ -99,11 +99,11 @@ it("getExtension test", () => { }); it("Greeter snapshot test with properties", () => { - const { asFragment } = render(); - expect(asFragment).toMatchSnapshot(); + const { baseElement } = render(); + expect(baseElement).toMatchSnapshot(); }); it("Greeter snapshot test without properties", () => { - const { asFragment } = render(); - expect(asFragment).toMatchSnapshot(); + const { baseElement } = render(); + expect(baseElement).toMatchSnapshot(); }); diff --git a/src/test/components/icon.spec.tsx b/src/test/components/icon.spec.tsx index 40d0257..6627aa4 100644 --- a/src/test/components/icon.spec.tsx +++ b/src/test/components/icon.spec.tsx @@ -8,13 +8,13 @@ const props = { }; it("Icon test", () => { - const { asFragment } = render(); - expect(asFragment).toMatchSnapshot(); + const { baseElement } = render(); + expect(baseElement).toMatchSnapshot(); }); it("Icon test (no size)", () => { - const { asFragment } = render(); - expect(asFragment).toMatchSnapshot(); + const { baseElement } = render(); + expect(baseElement).toMatchSnapshot(); }); it("IconButton test", () => { @@ -22,7 +22,7 @@ it("IconButton test", () => { , ); - expect(iconButton.asFragment).toMatchSnapshot(); + expect(iconButton.baseElement).toMatchSnapshot(); fireEvent.click(screen.getByText(/bug_report/i)); expect(props.onClick).toHaveBeenCalledTimes(1); diff --git a/src/test/components/imprint.spec.tsx b/src/test/components/imprint.spec.tsx index 4aeccfc..b3e8452 100644 --- a/src/test/components/imprint.spec.tsx +++ b/src/test/components/imprint.spec.tsx @@ -43,8 +43,8 @@ describe("imprint.tsx", () => { }); it("Tests Imprint", () => { - const { asFragment } = render(); - expect(asFragment).toMatchSnapshot(); + const { baseElement } = render(); + expect(baseElement).toMatchSnapshot(); }); it("Tests onClose with #imprint", () => { @@ -61,7 +61,7 @@ describe("imprint.tsx", () => { }); it("Tests ImprintField", () => { - const { asFragment } = render(); - expect(asFragment).toMatchSnapshot(); + const { baseElement } = render(); + expect(baseElement).toMatchSnapshot(); }); }); diff --git a/src/test/components/modal.spec.tsx b/src/test/components/modal.spec.tsx index bed4c7c..c3dec28 100644 --- a/src/test/components/modal.spec.tsx +++ b/src/test/components/modal.spec.tsx @@ -49,7 +49,7 @@ const setup = (props: IModalProps) => { describe("modal.tsx", () => { it("Tests modal with icon button", () => { const modal = setup(iconProps); - expect(modal.asFragment).toMatchSnapshot(); + expect(modal.baseElement).toMatchSnapshot(); fireEvent.click(modal.getByTestId("toggle-button")); fireEvent.click(modal.getByTestId("close-button")); expect(iconProps.onClose).toHaveBeenCalledTimes(2); @@ -57,7 +57,7 @@ describe("modal.tsx", () => { it("Tests modal with text button", () => { const modal = setup(textProps); - expect(modal.asFragment).toMatchSnapshot(); + expect(modal.baseElement).toMatchSnapshot(); fireEvent.click(modal.getByTestId("toggle-button")); fireEvent.click(modal.getByTestId("close-button")); expect(textProps.onClose).toHaveBeenCalledTimes(2); @@ -65,12 +65,12 @@ describe("modal.tsx", () => { it("Tests modal with neither", () => { const modal = setup(noneProps); - expect(modal.asFragment).toMatchSnapshot(); + expect(modal.baseElement).toMatchSnapshot(); }); it("Tests modal with icon", () => { const modal = setup(invalidIconProps); - expect(modal.asFragment).toMatchSnapshot(); + expect(modal.baseElement).toMatchSnapshot(); fireEvent.click(modal.getByTestId("toggle-button")); fireEvent.click(modal.getByTestId("close-button")); expect(invalidIconProps.onClose).toHaveBeenCalledTimes(2); @@ -78,7 +78,7 @@ describe("modal.tsx", () => { it("Tests modal without onClose behaviour", () => { const modal = setup(noneProps); - expect(modal.asFragment).toMatchSnapshot(); + expect(modal.baseElement).toMatchSnapshot(); fireEvent.click(modal.getByTestId("close-button")); expect(iconProps.onClose).toHaveBeenCalledTimes(0); }); diff --git a/src/test/components/searchBar.spec.tsx b/src/test/components/searchBar.spec.tsx index 0c8e46a..2f9e32a 100644 --- a/src/test/components/searchBar.spec.tsx +++ b/src/test/components/searchBar.spec.tsx @@ -56,12 +56,12 @@ describe("searchBar.tsx", () => { it("Tests SearchBar rendering with properties", () => { const { searchBar } = setup(); - expect(searchBar.asFragment).toMatchSnapshot(); + expect(searchBar.baseElement).toMatchSnapshot(); }); it("Tests searchBar rendering without properties", () => { const searchBar = render(); - expect(searchBar.asFragment).toMatchSnapshot(); + expect(searchBar.baseElement).toMatchSnapshot(); }); it("Tests handleQueryWithProvider", () => { diff --git a/src/test/components/select.spec.tsx b/src/test/components/select.spec.tsx index aaefca9..49ad248 100644 --- a/src/test/components/select.spec.tsx +++ b/src/test/components/select.spec.tsx @@ -15,15 +15,15 @@ const items: Array = [ describe("select.tsx", () => { it("Tests Select rendering", () => { - const { asFragment } = render( + const { baseElement } = render( , ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); it("Tests rendering of multiple Select elements", () => { - const { asFragment } = render( + const { baseElement } = render( <> { >, ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); it("Tests `current`-value with testId", () => { - const { asFragment } = render( + const { baseElement } = render( , ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); }); diff --git a/src/test/components/settings.spec.tsx b/src/test/components/settings.spec.tsx index 77b122c..56dd8dd 100644 --- a/src/test/components/settings.spec.tsx +++ b/src/test/components/settings.spec.tsx @@ -85,12 +85,12 @@ describe("settings.tsx", () => { }); it("Tests forms", () => { - const { asFragment } = render(); - expect(asFragment).toMatchSnapshot(); + const { baseElement } = render(); + expect(baseElement).toMatchSnapshot(); }); it("Tests tables", () => { - const { asFragment } = render( + const { baseElement } = render( @@ -103,26 +103,26 @@ describe("settings.tsx", () => {
    , ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); it("Tests sections", () => { - const { asFragment } = render( + const { baseElement } = render(
    Test
    , ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); it("Tests settings rendering", () => { propsList.forEach((props) => { - const { asFragment } = render( + const { baseElement } = render( , ); - expect(asFragment).toMatchSnapshot(); + expect(baseElement).toMatchSnapshot(); }); });