Skip to content

Commit

Permalink
Merge pull request #88 from Takt29/fix-frontend-test
Browse files Browse the repository at this point in the history
フロントエンドのテストを修正
  • Loading branch information
Takt29 authored Apr 6, 2024
2 parents 07dace0 + 22a3ffe commit a2af29b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions frontend/src/components/navbar/TopBar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test.each([
{ name: 'History', to: '/history' },
{ name: 'ChangeLog', to: '/changelog' },
{ name: 'Links', to: '/links' },
])('PCで${name}ページへのリンクが表示されている', async ({ name, to }) => {
])('PCで$nameページへのリンクが表示されている', async ({ name, to }) => {
setMedia({ width: '1000px' })
const { getByRole } = render(
<MemoryRouter>
Expand Down Expand Up @@ -55,10 +55,10 @@ test.each([
{ name: 'ChangeLog', to: '/changelog' },
{ name: 'Links', to: '/links' },
])(
'モバイルでボタンをクリックすると${name}ページへのリンクが表示される',
'モバイルでボタンをクリックすると$nameページへのリンクが表示される',
async ({ name, to }) => {
setMedia({ width: '400px' })
const { getByRole, user } = render(
const { getByRole, findByRole, user } = render(
<MemoryRouter>
<TopBar />
</MemoryRouter>,
Expand All @@ -67,7 +67,7 @@ test.each([
const button = getByRole('button')
await user.click(button)

const link = within(getByRole('navigation')).getByRole('link', {
const link = within(await findByRole('navigation')).getByRole('link', {
name,
})
expect(link).toBeInTheDocument()
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/test/vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import jestDomMatchers from '@testing-library/jest-dom/matchers'
import '@testing-library/jest-dom'
import { cleanup } from '@testing-library/react'
import { matchers as emotionMatchers } from '@emotion/jest'
import { afterEach, expect } from 'vitest'
import { matchMedia, cleanup as cleanupMatchMedia } from 'mock-match-media'

expect.extend(jestDomMatchers)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
expect.extend(emotionMatchers)
Expand Down

0 comments on commit a2af29b

Please sign in to comment.