Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get content when write unit test using Vitest #207

Open
fpt-tom-du opened this issue Aug 21, 2024 · 0 comments
Open

Cannot get content when write unit test using Vitest #207

fpt-tom-du opened this issue Aug 21, 2024 · 0 comments

Comments

@fpt-tom-du
Copy link

fpt-tom-du commented Aug 21, 2024

I got error: Unable to find an accessible element with the role "listitem".
I cannot get list of content to test action on that.

import {render, screen} from '@testing-library/react'
import {FileArray, FileBrowser} from 'chonky'
import {describe, expect, it} from 'vitest'

const DATA: {data: FileArray} = {
  data: [
    {
      name: '2024-02-05.jpg',
      id: '2024-02-05.jpg',
      thumbnailUrl: 'TEST',
      size: 122161,
      modDate: '2024-06-12T02:03:31.000Z'
    }
  ]
}

describe('FileBrowser', () => {
  it('should display file list', () => {
    render(<FileBrowser files={DATA.data} />)

    const fileItems = screen.getAllByRole('listitem')
    expect(fileItems).toHaveLength(2)
    expect(fileItems[0]).toHaveTextContent('2024-02-05.jpg')
  })
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant