作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 React Native 测试库中使用 getByRole
但我终究无法弄清楚语法
有问题的组件-
<Text
accessibilityRole={'button'}
accessibilityLabel={'upvote count'}
style={[styles.upvoteText, styles.upvoteCount]}>
{upvoteCount}
</Text>
和我的代码
expect(getByRole('button', {name: 'upvote count'} as MatcherOptions)).toBe(2)
最佳答案
所以,我正在研究类似的东西。我在 the docs 中看到了这个帮助解决这个问题:
<Text
accessibilityRole={'button'}
accessibilityLabel={'upvote count'}
style={[styles.upvoteText, styles.upvoteCount]}>
{upvoteCount}
</Text>
it('gets the button', () => {
const { getByA11yRole, getByA11yLabel } = render(<Text>foo</Text>);
expect(getByA11yRole('button')).toBeDefined();
expect(getbyA11yRole('upvote count')).toBeDefined();
});
关于reactjs - 如何使用 react-native-testing-library getByRole,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63907058/
我正在尝试在 React Native 测试库中使用 getByRole 但我终究无法弄清楚语法 有问题的组件- {upvoteCount} 和我的代码 expect(getByRole('b
我正在测试一个包含 Material Ui TextField 组件的组件(我们称之为 MyComponent): 我为此编写了测试: test('Checking the initial rend
我只是在尝试这个库,似乎无法通过他们的 ARIA Angular 色访问元素。 我使用 angular 10.0.6、jest 26.2.1 以及 jest-preset-angular 8.2.1
我有一个组件将过滤器列表呈现为可移动芯片,我正在尝试使用 react-testing-library 对其进行测试.我正在尝试按解释的可访问名称进行查询 here使用 getByRole . 组件:
我是一名优秀的程序员,十分优秀!