@testing-library/dom
Advanced tools
Comparing version 5.5.6 to 5.6.0
@@ -772,5 +772,5 @@ 'use strict'; | ||
function logRoles(container) { | ||
function prettyRoles(container) { | ||
var roles = getRoles(container); | ||
var rolesStr = Object.entries(roles).map(function (_ref10) { | ||
return Object.entries(roles).map(function (_ref10) { | ||
var role = _ref10[0], | ||
@@ -783,5 +783,8 @@ elements = _ref10[1]; | ||
return role + ":\n\n" + elementsString + "\n\n" + delimiterBar; | ||
}).join('\n'); // eslint-disable-next-line no-console | ||
}).join('\n'); | ||
} | ||
console.log(rolesStr); | ||
function logRoles(container) { | ||
// eslint-disable-next-line no-console | ||
console.log(prettyRoles(container)); | ||
} | ||
@@ -817,8 +820,8 @@ | ||
var getMultipleError$6 = function (c, id) { | ||
return "Found multiple elements by [role=" + id + "]"; | ||
var getMultipleError$6 = function (c, role) { | ||
return "Found multiple elements with the role \"" + role + "\""; | ||
}; | ||
var getMissingError$5 = function (c, id) { | ||
return "Unable to find an element by [role=" + id + "]"; | ||
var getMissingError$5 = function (container, role) { | ||
return ("\nUnable to find an element with the role \"" + role + "\"\n\nHere are the available roles:\n\n " + prettyRoles(container).replace(/\n/g, '\n ').replace(/\n\s\s\n/g, '\n\n') + "\n").trim(); | ||
}; | ||
@@ -825,0 +828,0 @@ |
@@ -766,5 +766,5 @@ import _extends from '@babel/runtime/helpers/esm/extends'; | ||
function logRoles(container) { | ||
function prettyRoles(container) { | ||
var roles = getRoles(container); | ||
var rolesStr = Object.entries(roles).map(function (_ref10) { | ||
return Object.entries(roles).map(function (_ref10) { | ||
var role = _ref10[0], | ||
@@ -777,5 +777,8 @@ elements = _ref10[1]; | ||
return role + ":\n\n" + elementsString + "\n\n" + delimiterBar; | ||
}).join('\n'); // eslint-disable-next-line no-console | ||
}).join('\n'); | ||
} | ||
console.log(rolesStr); | ||
function logRoles(container) { | ||
// eslint-disable-next-line no-console | ||
console.log(prettyRoles(container)); | ||
} | ||
@@ -811,8 +814,8 @@ | ||
var getMultipleError$6 = function (c, id) { | ||
return "Found multiple elements by [role=" + id + "]"; | ||
var getMultipleError$6 = function (c, role) { | ||
return "Found multiple elements with the role \"" + role + "\""; | ||
}; | ||
var getMissingError$5 = function (c, id) { | ||
return "Unable to find an element by [role=" + id + "]"; | ||
var getMissingError$5 = function (container, role) { | ||
return ("\nUnable to find an element with the role \"" + role + "\"\n\nHere are the available roles:\n\n " + prettyRoles(container).replace(/\n/g, '\n ').replace(/\n\s\s\n/g, '\n\n') + "\n").trim(); | ||
}; | ||
@@ -819,0 +822,0 @@ |
@@ -37,6 +37,12 @@ "use strict"; | ||
const getMultipleError = (c, id) => `Found multiple elements by [role=${id}]`; | ||
const getMultipleError = (c, role) => `Found multiple elements with the role "${role}"`; | ||
const getMissingError = (c, id) => `Unable to find an element by [role=${id}]`; | ||
const getMissingError = (container, role) => ` | ||
Unable to find an element with the role "${role}" | ||
Here are the available roles: | ||
${(0, _roleHelpers.prettyRoles)(container).replace(/\n/g, '\n ').replace(/\n\s\s\n/g, '\n\n')} | ||
`.trim(); | ||
const [queryByRole, getAllByRole, getByRole, findAllByRole, findByRole] = (0, _allUtils.buildQueries)(queryAllByRole, getMultipleError, getMissingError); | ||
@@ -43,0 +49,0 @@ exports.findByRole = findByRole; |
@@ -11,2 +11,3 @@ "use strict"; | ||
exports.getImplicitAriaRoles = getImplicitAriaRoles; | ||
exports.prettyRoles = prettyRoles; | ||
@@ -87,11 +88,14 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
function logRoles(container) { | ||
function prettyRoles(container) { | ||
const roles = getRoles(container); | ||
const rolesStr = Object.entries(roles).map(([role, elements]) => { | ||
return Object.entries(roles).map(([role, elements]) => { | ||
const delimiterBar = '-'.repeat(50); | ||
const elementsString = elements.map(el => (0, _queryHelpers.debugDOM)(el.cloneNode(false))).join('\n\n'); | ||
return `${role}:\n\n${elementsString}\n\n${delimiterBar}`; | ||
}).join('\n'); // eslint-disable-next-line no-console | ||
}).join('\n'); | ||
} | ||
console.log(rolesStr); | ||
function logRoles(container) { | ||
// eslint-disable-next-line no-console | ||
console.log(prettyRoles(container)); | ||
} |
{ | ||
"name": "@testing-library/dom", | ||
"version": "5.5.6", | ||
"version": "5.6.0", | ||
"description": "Simple and complete DOM testing utilities that encourage good testing practices.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1617886
14889