-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from DaleStudy/fix-vitest-setup
Vitest 설정 문제 해결
- Loading branch information
Showing
11 changed files
with
68 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @DaleStudy/leaderboard |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { faker } from "@faker-js/faker"; | ||
import { render, screen } from "@testing-library/react"; | ||
import { useRouteError } from "react-router-dom"; | ||
import { expect, test, vi } from "vitest"; | ||
import ErrorPage from "./ErrorPage"; | ||
|
||
vi.mock("react-router-dom"); | ||
|
||
test("displays the title and message", () => { | ||
vi.mocked(useRouteError).mockReturnValue({ | ||
statusText: faker.lorem.sentence(), | ||
message: faker.lorem.sentence(), | ||
}); | ||
|
||
render(<ErrorPage />); | ||
|
||
expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent(/oops!/i); | ||
expect( | ||
screen.getByText(/sorry, an unexpected error has occurred./i), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
test("displays the status text when available", () => { | ||
const statusText = faker.lorem.sentence(); | ||
const message = faker.lorem.sentence(); | ||
|
||
vi.mocked(useRouteError).mockReturnValue({ statusText, message }); | ||
|
||
render(<ErrorPage />); | ||
|
||
expect(screen.getByText(new RegExp(statusText, "i"))).toBeInTheDocument(); | ||
}); | ||
|
||
test("displays the error message when status text is not available", () => { | ||
const statusText = ""; | ||
const message = faker.lorem.sentence(); | ||
|
||
vi.mocked(useRouteError).mockReturnValue({ statusText, message }); | ||
|
||
render(<ErrorPage />); | ||
|
||
expect(screen.getByText(new RegExp(message, "i"))).toBeInTheDocument(); | ||
}); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters