@testing-library/dom
Advanced tools
Comparing version 8.12.0 to 8.13.0
@@ -25,2 +25,3 @@ "use strict"; | ||
name, | ||
description, | ||
trim, | ||
@@ -169,2 +170,11 @@ normalizer, | ||
}).filter(element => { | ||
if (description === undefined) { | ||
// Don't care | ||
return true; | ||
} | ||
return (0, _allUtils.matches)((0, _domAccessibilityApi.computeAccessibleDescription)(element, { | ||
computedStyleSupportsPseudoElements: (0, _allUtils.getConfig)().computedStyleSupportsPseudoElements | ||
}), element, description, text => text); | ||
}).filter(element => { | ||
return hidden === false ? (0, _roleHelpers.isInaccessible)(element, { | ||
@@ -213,3 +223,4 @@ isSubtreeInaccessible: cachedIsSubtreeInaccessible | ||
hidden = (0, _allUtils.getConfig)().defaultHidden, | ||
name | ||
name, | ||
description | ||
} = {}) => { | ||
@@ -224,3 +235,4 @@ if ((0, _allUtils.getConfig)()._disableExpensiveErrorDiagnostics) { | ||
hidden, | ||
includeName: name !== undefined | ||
includeName: name !== undefined, | ||
includeDescription: description !== undefined | ||
}); | ||
@@ -254,4 +266,14 @@ }); | ||
let descriptionHint = ''; | ||
if (description === undefined) { | ||
descriptionHint = ''; | ||
} else if (typeof description === 'string') { | ||
descriptionHint = ` and description "${description}"`; | ||
} else { | ||
descriptionHint = ` and description \`${description}\``; | ||
} | ||
return ` | ||
Unable to find an ${hidden === false ? 'accessible ' : ''}element with the role "${role}"${nameHint} | ||
Unable to find an ${hidden === false ? 'accessible ' : ''}element with the role "${role}"${nameHint}${descriptionHint} | ||
@@ -258,0 +280,0 @@ ${roleMessage}`.trim(); |
@@ -204,3 +204,4 @@ "use strict"; | ||
function prettyRoles(dom, { | ||
hidden | ||
hidden, | ||
includeDescription | ||
}) { | ||
@@ -218,2 +219,10 @@ const roles = getRoles(dom, { | ||
const domString = (0, _prettyDom.prettyDOM)(el.cloneNode(false)); | ||
if (includeDescription) { | ||
const descriptionString = `Description "${(0, _domAccessibilityApi.computeAccessibleDescription)(el, { | ||
computedStyleSupportsPseudoElements: (0, _config.getConfig)().computedStyleSupportsPseudoElements | ||
})}":\n`; | ||
return `${nameString}${descriptionString}${domString}`; | ||
} | ||
return `${nameString}${domString}`; | ||
@@ -220,0 +229,0 @@ }).join('\n\n'); |
{ | ||
"name": "@testing-library/dom", | ||
"version": "8.12.0", | ||
"version": "8.13.0", | ||
"description": "Simple and complete DOM testing utilities that encourage good testing practices.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -118,2 +118,9 @@ import {ByRoleMatcher, Matcher, MatcherOptions} from './matches' | ||
| ((accessibleName: string, element: Element) => boolean) | ||
/** | ||
* Only considers elements with the specified accessible description. | ||
*/ | ||
description?: | ||
| RegExp | ||
| string | ||
| ((accessibleDescription: string, element: Element) => boolean) | ||
} | ||
@@ -120,0 +127,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
2516556
22297