Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/__node_tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,23 @@ test('works without a browser context on a dom node (JSDOM Fragment)', () => {
/>
`)
})

test('byRole works without a global DOM', () => {
const {
window: {
document: {body: container},
},
} = new JSDOM(`
<html>
<body>
<button>Say "Hello, Dave!"</button>
</body>
</html>
`)

expect(dtl.getByRole(container, 'button')).toMatchInlineSnapshot(`
<button>
Say "Hello, Dave!"
</button>
`)
})
1 change: 1 addition & 0 deletions src/role-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const elementRoleList = buildElementRoleList(elementRoles)
* @returns {boolean} true if excluded, otherwise false
*/
function shouldExcludeFromA11yTree(element) {
const window = element.ownerDocument.defaultView
const computedStyle = window.getComputedStyle(element)
// since visibility is inherited we can exit early
if (computedStyle.visibility === 'hidden') {
Expand Down