开玩笑的测试,如果溢出隐藏的元素是否可见
我有一个像滑块一样的反应组件。我想测试溢出隐藏的元素之一是否可见。
到目前为止,我拥有的是
const prevBtn = screen.getByRole('button', { name: /prev slide/i })
const juneTwentySix = await screen.findByTestId('Sun 26 Jun')
const juneThird = await screen.findByTestId('Sun 30 Jun')
expect(prevBtn).toBeDisabled()
expect(juneTwentySix).toBeVisible() <-- ok
expect(juneThird).toBeInTheDocument() <-- it's in the DOM, so it's ok to be in the document
expect(juneThird).not.toBeVisible() <-- this is where I want to check if the element is visible or not.
该滑块的建造方式: 父组件具有固定宽度:I 300px,是什么使子组件(包含日期的一个)是transform:translatex(-U {$ {Currentslide * 100}%)
>
I have a react component that behaves like a slider. I wanna test if one of the elements that is hidden by the overflow is visible or not.
What I have so far is
const prevBtn = screen.getByRole('button', { name: /prev slide/i })
const juneTwentySix = await screen.findByTestId('Sun 26 Jun')
const juneThird = await screen.findByTestId('Sun 30 Jun')
expect(prevBtn).toBeDisabled()
expect(juneTwentySix).toBeVisible() <-- ok
expect(juneThird).toBeInTheDocument() <-- it's in the DOM, so it's ok to be in the document
expect(juneThird).not.toBeVisible() <-- this is where I want to check if the element is visible or not.
How is this slider built:
The parent component has a fixed width: ie 300px, and what makes the child component (the one that contains the dates) is transform: translateX(-${currentSlide * 100}%)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论