Skip to content

Commit

Permalink
Merge pull request #1498 from skaut/react-testing-library
Browse files Browse the repository at this point in the history
Replaced react-test-renderer with @testing-library/react
  • Loading branch information
marekdedic authored Jun 20, 2024
2 parents ba8a5f0 + d36c0b1 commit f46e90d
Show file tree
Hide file tree
Showing 29 changed files with 1,078 additions and 5,793 deletions.
72 changes: 31 additions & 41 deletions packages/frontend/__tests__/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render } from "@testing-library/react";
import { mocked } from "jest-mock";
import { MemoryRouter } from "react-router-dom";
import renderer from "react-test-renderer";
import * as swr from "swr";

import { App } from "../src/App";
Expand All @@ -21,14 +21,12 @@ describe("App", () => {
isValidating: false,
isLoading: false,
});
const tree = renderer
.create(
<MemoryRouter>
<App />
</MemoryRouter>,
)
.toJSON();
expect(tree).toMatchSnapshot();
const { container } = render(
<MemoryRouter>
<App />
</MemoryRouter>,
);
expect(container.firstChild).toMatchSnapshot();
});

test("should render projects correctly", () => {
Expand All @@ -39,14 +37,12 @@ describe("App", () => {
isValidating: false,
isLoading: false,
});
const tree = renderer
.create(
<MemoryRouter initialEntries={["/projekty"]}>
<App />
</MemoryRouter>,
)
.toJSON();
expect(tree).toMatchSnapshot();
const { container } = render(
<MemoryRouter initialEntries={["/projekty"]}>
<App />
</MemoryRouter>,
);
expect(container.firstChild).toMatchSnapshot();
});

test("should render project listing correctly", () => {
Expand All @@ -57,14 +53,12 @@ describe("App", () => {
isValidating: false,
isLoading: false,
});
const tree = renderer
.create(
<MemoryRouter initialEntries={["/skaut/skaut-google-drive-gallery"]}>
<App />
</MemoryRouter>,
)
.toJSON();
expect(tree).toMatchSnapshot();
const { container } = render(
<MemoryRouter initialEntries={["/skaut/skaut-google-drive-gallery"]}>
<App />
</MemoryRouter>,
);
expect(container.firstChild).toMatchSnapshot();
});

test("should render issue listing correctly", () => {
Expand All @@ -75,14 +69,12 @@ describe("App", () => {
isValidating: false,
isLoading: false,
});
const tree = renderer
.create(
<MemoryRouter initialEntries={["/skaut/skaut-google-drive-gallery/3"]}>
<App />
</MemoryRouter>,
)
.toJSON();
expect(tree).toMatchSnapshot();
const { container } = render(
<MemoryRouter initialEntries={["/skaut/skaut-google-drive-gallery/3"]}>
<App />
</MemoryRouter>,
);
expect(container.firstChild).toMatchSnapshot();
});

test("should handle error gracefully", () => {
Expand All @@ -93,13 +85,11 @@ describe("App", () => {
isValidating: false,
isLoading: false,
});
const tree = renderer
.create(
<MemoryRouter>
<App />
</MemoryRouter>,
)
.toJSON();
expect(tree).toMatchSnapshot();
const { container } = render(
<MemoryRouter>
<App />
</MemoryRouter>,
);
expect(container.firstChild).toMatchSnapshot();
});
});
Loading

0 comments on commit f46e90d

Please sign in to comment.