@testing-library/dom
Advanced tools
Comparing version 6.12.2 to 6.13.0
@@ -14,97 +14,2 @@ 'use strict'; | ||
function fuzzyMatches(textToMatch, node, matcher, normalizer) { | ||
if (typeof textToMatch !== 'string') { | ||
return false; | ||
} | ||
var normalizedText = normalizer(textToMatch); | ||
if (typeof matcher === 'string') { | ||
return normalizedText.toLowerCase().includes(matcher.toLowerCase()); | ||
} else if (typeof matcher === 'function') { | ||
return matcher(normalizedText, node); | ||
} else { | ||
return matcher.test(normalizedText); | ||
} | ||
} | ||
function matches(textToMatch, node, matcher, normalizer) { | ||
if (typeof textToMatch !== 'string') { | ||
return false; | ||
} | ||
var normalizedText = normalizer(textToMatch); | ||
if (typeof matcher === 'string') { | ||
return normalizedText === matcher; | ||
} else if (typeof matcher === 'function') { | ||
return matcher(normalizedText, node); | ||
} else { | ||
return matcher.test(normalizedText); | ||
} | ||
} | ||
function getDefaultNormalizer(_temp) { | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
_ref$trim = _ref.trim, | ||
trim = _ref$trim === void 0 ? true : _ref$trim, | ||
_ref$collapseWhitespa = _ref.collapseWhitespace, | ||
collapseWhitespace = _ref$collapseWhitespa === void 0 ? true : _ref$collapseWhitespa; | ||
return function (text) { | ||
var normalizedText = text; | ||
normalizedText = trim ? normalizedText.trim() : normalizedText; | ||
normalizedText = collapseWhitespace ? normalizedText.replace(/\s+/g, ' ') : normalizedText; | ||
return normalizedText; | ||
}; | ||
} | ||
/** | ||
* Constructs a normalizer to pass to functions in matches.js | ||
* @param {boolean|undefined} trim The user-specified value for `trim`, without | ||
* any defaulting having been applied | ||
* @param {boolean|undefined} collapseWhitespace The user-specified value for | ||
* `collapseWhitespace`, without any defaulting having been applied | ||
* @param {Function|undefined} normalizer The user-specified normalizer | ||
* @returns {Function} A normalizer | ||
*/ | ||
function makeNormalizer(_ref2) { | ||
var trim = _ref2.trim, | ||
collapseWhitespace = _ref2.collapseWhitespace, | ||
normalizer = _ref2.normalizer; | ||
if (normalizer) { | ||
// User has specified a custom normalizer | ||
if (typeof trim !== 'undefined' || typeof collapseWhitespace !== 'undefined') { | ||
// They've also specified a value for trim or collapseWhitespace | ||
throw new Error('trim and collapseWhitespace are not supported with a normalizer. ' + 'If you want to use the default trim and collapseWhitespace logic in your normalizer, ' + 'use "getDefaultNormalizer({trim, collapseWhitespace})" and compose that into your normalizer'); | ||
} | ||
return normalizer; | ||
} else { | ||
// No custom normalizer specified. Just use default. | ||
return getDefaultNormalizer({ | ||
trim: trim, | ||
collapseWhitespace: collapseWhitespace | ||
}); | ||
} | ||
} | ||
// Constant node.nodeType for text nodes, see: | ||
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#Node_type_constants | ||
var TEXT_NODE = 3; | ||
function getNodeText(node) { | ||
if (node.matches('input[type=submit], input[type=button]')) { | ||
return node.value; | ||
} | ||
return Array.from(node.childNodes).filter(function (child) { | ||
return child.nodeType === TEXT_NODE && Boolean(child.textContent); | ||
}).map(function (c) { | ||
return c.textContent; | ||
}).join(''); | ||
} | ||
var globalObj = typeof window === 'undefined' ? global : window; // Currently this fn only supports jest timers, but it could support other test runners in the future. | ||
@@ -222,5 +127,5 @@ | ||
// It would be cleaner for this to live inside './queries', but | ||
// other parts of the code assume that all exports from | ||
// './queries' are query functions. | ||
var config = { | ||
@@ -240,3 +145,7 @@ testIdAttribute: 'data-testid', | ||
// default value for the `hidden` option in `ByRole` queries | ||
defaultHidden: false | ||
defaultHidden: false, | ||
// called when getBy* queries fail. (message, container) => Error | ||
getElementError: function getElementError(message, container) { | ||
return new Error([message, prettyDOM(container)].filter(Boolean).join('\n\n')); | ||
} | ||
}; | ||
@@ -257,2 +166,97 @@ function configure(newConfig) { | ||
function fuzzyMatches(textToMatch, node, matcher, normalizer) { | ||
if (typeof textToMatch !== 'string') { | ||
return false; | ||
} | ||
var normalizedText = normalizer(textToMatch); | ||
if (typeof matcher === 'string') { | ||
return normalizedText.toLowerCase().includes(matcher.toLowerCase()); | ||
} else if (typeof matcher === 'function') { | ||
return matcher(normalizedText, node); | ||
} else { | ||
return matcher.test(normalizedText); | ||
} | ||
} | ||
function matches(textToMatch, node, matcher, normalizer) { | ||
if (typeof textToMatch !== 'string') { | ||
return false; | ||
} | ||
var normalizedText = normalizer(textToMatch); | ||
if (typeof matcher === 'string') { | ||
return normalizedText === matcher; | ||
} else if (typeof matcher === 'function') { | ||
return matcher(normalizedText, node); | ||
} else { | ||
return matcher.test(normalizedText); | ||
} | ||
} | ||
function getDefaultNormalizer(_temp) { | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
_ref$trim = _ref.trim, | ||
trim = _ref$trim === void 0 ? true : _ref$trim, | ||
_ref$collapseWhitespa = _ref.collapseWhitespace, | ||
collapseWhitespace = _ref$collapseWhitespa === void 0 ? true : _ref$collapseWhitespa; | ||
return function (text) { | ||
var normalizedText = text; | ||
normalizedText = trim ? normalizedText.trim() : normalizedText; | ||
normalizedText = collapseWhitespace ? normalizedText.replace(/\s+/g, ' ') : normalizedText; | ||
return normalizedText; | ||
}; | ||
} | ||
/** | ||
* Constructs a normalizer to pass to functions in matches.js | ||
* @param {boolean|undefined} trim The user-specified value for `trim`, without | ||
* any defaulting having been applied | ||
* @param {boolean|undefined} collapseWhitespace The user-specified value for | ||
* `collapseWhitespace`, without any defaulting having been applied | ||
* @param {Function|undefined} normalizer The user-specified normalizer | ||
* @returns {Function} A normalizer | ||
*/ | ||
function makeNormalizer(_ref2) { | ||
var trim = _ref2.trim, | ||
collapseWhitespace = _ref2.collapseWhitespace, | ||
normalizer = _ref2.normalizer; | ||
if (normalizer) { | ||
// User has specified a custom normalizer | ||
if (typeof trim !== 'undefined' || typeof collapseWhitespace !== 'undefined') { | ||
// They've also specified a value for trim or collapseWhitespace | ||
throw new Error('trim and collapseWhitespace are not supported with a normalizer. ' + 'If you want to use the default trim and collapseWhitespace logic in your normalizer, ' + 'use "getDefaultNormalizer({trim, collapseWhitespace})" and compose that into your normalizer'); | ||
} | ||
return normalizer; | ||
} else { | ||
// No custom normalizer specified. Just use default. | ||
return getDefaultNormalizer({ | ||
trim: trim, | ||
collapseWhitespace: collapseWhitespace | ||
}); | ||
} | ||
} | ||
// Constant node.nodeType for text nodes, see: | ||
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#Node_type_constants | ||
var TEXT_NODE = 3; | ||
function getNodeText(node) { | ||
if (node.matches('input[type=submit], input[type=button]')) { | ||
return node.value; | ||
} | ||
return Array.from(node.childNodes).filter(function (child) { | ||
return child.nodeType === TEXT_NODE && Boolean(child.textContent); | ||
}).map(function (c) { | ||
return c.textContent; | ||
}).join(''); | ||
} | ||
function waitForElement(callback, _temp) { | ||
@@ -330,8 +334,4 @@ var _ref = _temp === void 0 ? {} : _temp, | ||
function getElementError(message, container) { | ||
return new Error([message, prettyDOM(container)].filter(Boolean).join('\n\n')); | ||
} | ||
function getMultipleElementsFoundError(message, container) { | ||
return getElementError(message + "\n\n(If this is intentional, then use the `*AllBy*` variant of the query (like `queryAllByText`, `getAllByText`, or `findAllByText`)).", container); | ||
return getConfig().getElementError(message + "\n\n(If this is intentional, then use the `*AllBy*` variant of the query (like `queryAllByText`, `getAllByText`, or `findAllByText`)).", container); | ||
} | ||
@@ -402,3 +402,3 @@ | ||
if (!els.length) { | ||
throw getElementError(getMissingError.apply(void 0, [container].concat(args)), container); | ||
throw getConfig().getElementError(getMissingError.apply(void 0, [container].concat(args)), container); | ||
} | ||
@@ -431,3 +431,2 @@ | ||
__proto__: null, | ||
getElementError: getElementError, | ||
getMultipleElementsFoundError: getMultipleElementsFoundError, | ||
@@ -595,5 +594,5 @@ queryAllByAttribute: queryAllByAttribute, | ||
if (labels.length) { | ||
throw getElementError("Found a label with the text of: " + text + ", however no form control was found associated to that label. Make sure you're using the \"for\" attribute or \"aria-labelledby\" attribute correctly.", container); | ||
throw getConfig().getElementError("Found a label with the text of: " + text + ", however no form control was found associated to that label. Make sure you're using the \"for\" attribute or \"aria-labelledby\" attribute correctly.", container); | ||
} else { | ||
throw getElementError("Unable to find a label with the text of: " + text, container); | ||
throw getConfig().getElementError("Unable to find a label with the text of: " + text, container); | ||
} | ||
@@ -2073,3 +2072,2 @@ } | ||
exports.getDefaultNormalizer = getDefaultNormalizer; | ||
exports.getElementError = getElementError; | ||
exports.getMultipleElementsFoundError = getMultipleElementsFoundError; | ||
@@ -2076,0 +2074,0 @@ exports.getNodeText = getNodeText; |
@@ -8,97 +8,2 @@ import _extends from '@babel/runtime/helpers/esm/extends'; | ||
function fuzzyMatches(textToMatch, node, matcher, normalizer) { | ||
if (typeof textToMatch !== 'string') { | ||
return false; | ||
} | ||
var normalizedText = normalizer(textToMatch); | ||
if (typeof matcher === 'string') { | ||
return normalizedText.toLowerCase().includes(matcher.toLowerCase()); | ||
} else if (typeof matcher === 'function') { | ||
return matcher(normalizedText, node); | ||
} else { | ||
return matcher.test(normalizedText); | ||
} | ||
} | ||
function matches(textToMatch, node, matcher, normalizer) { | ||
if (typeof textToMatch !== 'string') { | ||
return false; | ||
} | ||
var normalizedText = normalizer(textToMatch); | ||
if (typeof matcher === 'string') { | ||
return normalizedText === matcher; | ||
} else if (typeof matcher === 'function') { | ||
return matcher(normalizedText, node); | ||
} else { | ||
return matcher.test(normalizedText); | ||
} | ||
} | ||
function getDefaultNormalizer(_temp) { | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
_ref$trim = _ref.trim, | ||
trim = _ref$trim === void 0 ? true : _ref$trim, | ||
_ref$collapseWhitespa = _ref.collapseWhitespace, | ||
collapseWhitespace = _ref$collapseWhitespa === void 0 ? true : _ref$collapseWhitespa; | ||
return function (text) { | ||
var normalizedText = text; | ||
normalizedText = trim ? normalizedText.trim() : normalizedText; | ||
normalizedText = collapseWhitespace ? normalizedText.replace(/\s+/g, ' ') : normalizedText; | ||
return normalizedText; | ||
}; | ||
} | ||
/** | ||
* Constructs a normalizer to pass to functions in matches.js | ||
* @param {boolean|undefined} trim The user-specified value for `trim`, without | ||
* any defaulting having been applied | ||
* @param {boolean|undefined} collapseWhitespace The user-specified value for | ||
* `collapseWhitespace`, without any defaulting having been applied | ||
* @param {Function|undefined} normalizer The user-specified normalizer | ||
* @returns {Function} A normalizer | ||
*/ | ||
function makeNormalizer(_ref2) { | ||
var trim = _ref2.trim, | ||
collapseWhitespace = _ref2.collapseWhitespace, | ||
normalizer = _ref2.normalizer; | ||
if (normalizer) { | ||
// User has specified a custom normalizer | ||
if (typeof trim !== 'undefined' || typeof collapseWhitespace !== 'undefined') { | ||
// They've also specified a value for trim or collapseWhitespace | ||
throw new Error('trim and collapseWhitespace are not supported with a normalizer. ' + 'If you want to use the default trim and collapseWhitespace logic in your normalizer, ' + 'use "getDefaultNormalizer({trim, collapseWhitespace})" and compose that into your normalizer'); | ||
} | ||
return normalizer; | ||
} else { | ||
// No custom normalizer specified. Just use default. | ||
return getDefaultNormalizer({ | ||
trim: trim, | ||
collapseWhitespace: collapseWhitespace | ||
}); | ||
} | ||
} | ||
// Constant node.nodeType for text nodes, see: | ||
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#Node_type_constants | ||
var TEXT_NODE = 3; | ||
function getNodeText(node) { | ||
if (node.matches('input[type=submit], input[type=button]')) { | ||
return node.value; | ||
} | ||
return Array.from(node.childNodes).filter(function (child) { | ||
return child.nodeType === TEXT_NODE && Boolean(child.textContent); | ||
}).map(function (c) { | ||
return c.textContent; | ||
}).join(''); | ||
} | ||
var globalObj = typeof window === 'undefined' ? global : window; // Currently this fn only supports jest timers, but it could support other test runners in the future. | ||
@@ -216,5 +121,5 @@ | ||
// It would be cleaner for this to live inside './queries', but | ||
// other parts of the code assume that all exports from | ||
// './queries' are query functions. | ||
var config = { | ||
@@ -234,3 +139,7 @@ testIdAttribute: 'data-testid', | ||
// default value for the `hidden` option in `ByRole` queries | ||
defaultHidden: false | ||
defaultHidden: false, | ||
// called when getBy* queries fail. (message, container) => Error | ||
getElementError: function getElementError(message, container) { | ||
return new Error([message, prettyDOM(container)].filter(Boolean).join('\n\n')); | ||
} | ||
}; | ||
@@ -251,2 +160,97 @@ function configure(newConfig) { | ||
function fuzzyMatches(textToMatch, node, matcher, normalizer) { | ||
if (typeof textToMatch !== 'string') { | ||
return false; | ||
} | ||
var normalizedText = normalizer(textToMatch); | ||
if (typeof matcher === 'string') { | ||
return normalizedText.toLowerCase().includes(matcher.toLowerCase()); | ||
} else if (typeof matcher === 'function') { | ||
return matcher(normalizedText, node); | ||
} else { | ||
return matcher.test(normalizedText); | ||
} | ||
} | ||
function matches(textToMatch, node, matcher, normalizer) { | ||
if (typeof textToMatch !== 'string') { | ||
return false; | ||
} | ||
var normalizedText = normalizer(textToMatch); | ||
if (typeof matcher === 'string') { | ||
return normalizedText === matcher; | ||
} else if (typeof matcher === 'function') { | ||
return matcher(normalizedText, node); | ||
} else { | ||
return matcher.test(normalizedText); | ||
} | ||
} | ||
function getDefaultNormalizer(_temp) { | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
_ref$trim = _ref.trim, | ||
trim = _ref$trim === void 0 ? true : _ref$trim, | ||
_ref$collapseWhitespa = _ref.collapseWhitespace, | ||
collapseWhitespace = _ref$collapseWhitespa === void 0 ? true : _ref$collapseWhitespa; | ||
return function (text) { | ||
var normalizedText = text; | ||
normalizedText = trim ? normalizedText.trim() : normalizedText; | ||
normalizedText = collapseWhitespace ? normalizedText.replace(/\s+/g, ' ') : normalizedText; | ||
return normalizedText; | ||
}; | ||
} | ||
/** | ||
* Constructs a normalizer to pass to functions in matches.js | ||
* @param {boolean|undefined} trim The user-specified value for `trim`, without | ||
* any defaulting having been applied | ||
* @param {boolean|undefined} collapseWhitespace The user-specified value for | ||
* `collapseWhitespace`, without any defaulting having been applied | ||
* @param {Function|undefined} normalizer The user-specified normalizer | ||
* @returns {Function} A normalizer | ||
*/ | ||
function makeNormalizer(_ref2) { | ||
var trim = _ref2.trim, | ||
collapseWhitespace = _ref2.collapseWhitespace, | ||
normalizer = _ref2.normalizer; | ||
if (normalizer) { | ||
// User has specified a custom normalizer | ||
if (typeof trim !== 'undefined' || typeof collapseWhitespace !== 'undefined') { | ||
// They've also specified a value for trim or collapseWhitespace | ||
throw new Error('trim and collapseWhitespace are not supported with a normalizer. ' + 'If you want to use the default trim and collapseWhitespace logic in your normalizer, ' + 'use "getDefaultNormalizer({trim, collapseWhitespace})" and compose that into your normalizer'); | ||
} | ||
return normalizer; | ||
} else { | ||
// No custom normalizer specified. Just use default. | ||
return getDefaultNormalizer({ | ||
trim: trim, | ||
collapseWhitespace: collapseWhitespace | ||
}); | ||
} | ||
} | ||
// Constant node.nodeType for text nodes, see: | ||
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#Node_type_constants | ||
var TEXT_NODE = 3; | ||
function getNodeText(node) { | ||
if (node.matches('input[type=submit], input[type=button]')) { | ||
return node.value; | ||
} | ||
return Array.from(node.childNodes).filter(function (child) { | ||
return child.nodeType === TEXT_NODE && Boolean(child.textContent); | ||
}).map(function (c) { | ||
return c.textContent; | ||
}).join(''); | ||
} | ||
function waitForElement(callback, _temp) { | ||
@@ -324,8 +328,4 @@ var _ref = _temp === void 0 ? {} : _temp, | ||
function getElementError(message, container) { | ||
return new Error([message, prettyDOM(container)].filter(Boolean).join('\n\n')); | ||
} | ||
function getMultipleElementsFoundError(message, container) { | ||
return getElementError(message + "\n\n(If this is intentional, then use the `*AllBy*` variant of the query (like `queryAllByText`, `getAllByText`, or `findAllByText`)).", container); | ||
return getConfig().getElementError(message + "\n\n(If this is intentional, then use the `*AllBy*` variant of the query (like `queryAllByText`, `getAllByText`, or `findAllByText`)).", container); | ||
} | ||
@@ -396,3 +396,3 @@ | ||
if (!els.length) { | ||
throw getElementError(getMissingError.apply(void 0, [container].concat(args)), container); | ||
throw getConfig().getElementError(getMissingError.apply(void 0, [container].concat(args)), container); | ||
} | ||
@@ -425,3 +425,2 @@ | ||
__proto__: null, | ||
getElementError: getElementError, | ||
getMultipleElementsFoundError: getMultipleElementsFoundError, | ||
@@ -589,5 +588,5 @@ queryAllByAttribute: queryAllByAttribute, | ||
if (labels.length) { | ||
throw getElementError("Found a label with the text of: " + text + ", however no form control was found associated to that label. Make sure you're using the \"for\" attribute or \"aria-labelledby\" attribute correctly.", container); | ||
throw getConfig().getElementError("Found a label with the text of: " + text + ", however no form control was found associated to that label. Make sure you're using the \"for\" attribute or \"aria-labelledby\" attribute correctly.", container); | ||
} else { | ||
throw getElementError("Unable to find a label with the text of: " + text, container); | ||
throw getConfig().getElementError("Unable to find a label with the text of: " + text, container); | ||
} | ||
@@ -2029,2 +2028,2 @@ } | ||
export { getQueriesForElement as bindElementToQueries, buildQueries, configure, createEvent, findAllByAltText, findAllByDisplayValue, findAllByLabelText, findAllByPlaceholderText, findAllByRole, findAllByTestId, findAllByText, findAllByTitle, findByAltText, findByDisplayValue, findByLabelText, findByPlaceholderText, findByRole, findByTestId, findByText, findByTitle, fireEvent, getAllByAltText, getAllByDisplayValue, getAllByLabelText, getAllByPlaceholderText, getAllByRole, getAllByTestId, getAllByText, getAllByTitle, getByAltText, getByDisplayValue, getByLabelText, getByPlaceholderText, getByRole, getByTestId, getByText, getByTitle, getDefaultNormalizer, getElementError, getMultipleElementsFoundError, getNodeText, getQueriesForElement, getRoles, isInaccessible, logDOM, logRoles, makeFindQuery, makeGetAllQuery, makeSingleQuery, prettyDOM, queries, queryAllByAltText, queryAllByAttribute, queryAllByDisplayValue, queryAllByLabelText, queryAllByPlaceholderText, queryAllByRole, queryAllByTestId, queryAllByText, queryAllByTitle, queryByAltText, queryByAttribute, queryByDisplayValue, queryByLabelText, queryByPlaceholderText, queryByRole, queryByTestId, queryByText, queryByTitle, queryHelpers, screen, waitWrapper as wait, waitForDomChangeWrapper as waitForDomChange, waitForElementWrapper as waitForElement, waitForElementToBeRemovedWrapper as waitForElementToBeRemoved, getQueriesForElement as within }; | ||
export { getQueriesForElement as bindElementToQueries, buildQueries, configure, createEvent, findAllByAltText, findAllByDisplayValue, findAllByLabelText, findAllByPlaceholderText, findAllByRole, findAllByTestId, findAllByText, findAllByTitle, findByAltText, findByDisplayValue, findByLabelText, findByPlaceholderText, findByRole, findByTestId, findByText, findByTitle, fireEvent, getAllByAltText, getAllByDisplayValue, getAllByLabelText, getAllByPlaceholderText, getAllByRole, getAllByTestId, getAllByText, getAllByTitle, getByAltText, getByDisplayValue, getByLabelText, getByPlaceholderText, getByRole, getByTestId, getByText, getByTitle, getDefaultNormalizer, getMultipleElementsFoundError, getNodeText, getQueriesForElement, getRoles, isInaccessible, logDOM, logRoles, makeFindQuery, makeGetAllQuery, makeSingleQuery, prettyDOM, queries, queryAllByAltText, queryAllByAttribute, queryAllByDisplayValue, queryAllByLabelText, queryAllByPlaceholderText, queryAllByRole, queryAllByTestId, queryAllByText, queryAllByTitle, queryByAltText, queryByAttribute, queryByDisplayValue, queryByLabelText, queryByPlaceholderText, queryByRole, queryByTestId, queryByText, queryByTitle, queryHelpers, screen, waitWrapper as wait, waitForDomChangeWrapper as waitForDomChange, waitForElementWrapper as waitForElement, waitForElementToBeRemovedWrapper as waitForElementToBeRemoved, getQueriesForElement as within }; |
@@ -13,2 +13,4 @@ "use strict"; | ||
var _prettyDom = require("./pretty-dom"); | ||
// It would be cleaner for this to live inside './queries', but | ||
@@ -29,3 +31,9 @@ // other parts of the code assume that all exports from | ||
// default value for the `hidden` option in `ByRole` queries | ||
defaultHidden: false | ||
defaultHidden: false, | ||
// called when getBy* queries fail. (message, container) => Error | ||
getElementError(message, container) { | ||
return new Error([message, (0, _prettyDom.prettyDOM)(container)].filter(Boolean).join('\n\n')); | ||
} | ||
}; | ||
@@ -32,0 +40,0 @@ |
@@ -10,2 +10,4 @@ "use strict"; | ||
var _config = require("../config"); | ||
var _allUtils = require("./all-utils"); | ||
@@ -111,5 +113,5 @@ | ||
if (labels.length) { | ||
throw (0, _allUtils.getElementError)(`Found a label with the text of: ${text}, however no form control was found associated to that label. Make sure you're using the "for" attribute or "aria-labelledby" attribute correctly.`, container); | ||
throw (0, _config.getConfig)().getElementError(`Found a label with the text of: ${text}, however no form control was found associated to that label. Make sure you're using the "for" attribute or "aria-labelledby" attribute correctly.`, container); | ||
} else { | ||
throw (0, _allUtils.getElementError)(`Unable to find a label with the text of: ${text}`, container); | ||
throw (0, _config.getConfig)().getElementError(`Unable to find a label with the text of: ${text}`, container); | ||
} | ||
@@ -116,0 +118,0 @@ } |
@@ -6,3 +6,2 @@ "use strict"; | ||
}); | ||
exports.getElementError = getElementError; | ||
exports.getMultipleElementsFoundError = getMultipleElementsFoundError; | ||
@@ -16,4 +15,2 @@ exports.queryAllByAttribute = queryAllByAttribute; | ||
var _prettyDom = require("./pretty-dom"); | ||
var _matches = require("./matches"); | ||
@@ -23,8 +20,6 @@ | ||
function getElementError(message, container) { | ||
return new Error([message, (0, _prettyDom.prettyDOM)(container)].filter(Boolean).join('\n\n')); | ||
} | ||
var _config = require("./config"); | ||
function getMultipleElementsFoundError(message, container) { | ||
return getElementError(`${message}\n\n(If this is intentional, then use the \`*AllBy*\` variant of the query (like \`queryAllByText\`, \`getAllByText\`, or \`findAllByText\`)).`, container); | ||
return (0, _config.getConfig)().getElementError(`${message}\n\n(If this is intentional, then use the \`*AllBy*\` variant of the query (like \`queryAllByText\`, \`getAllByText\`, or \`findAllByText\`)).`, container); | ||
} | ||
@@ -79,3 +74,3 @@ | ||
if (!els.length) { | ||
throw getElementError(getMissingError(container, ...args), container); | ||
throw (0, _config.getConfig)().getElementError(getMissingError(container, ...args), container); | ||
} | ||
@@ -82,0 +77,0 @@ |
{ | ||
"name": "@testing-library/dom", | ||
"version": "6.12.2", | ||
"version": "6.13.0", | ||
"description": "Simple and complete DOM testing utilities that encourage good testing practices.", | ||
@@ -55,4 +55,4 @@ "main": "dist/index.js", | ||
"jest-watch-select-projects": "^1.0.0", | ||
"jsdom": "^15.1.1", | ||
"kcd-scripts": "^1.7.0" | ||
"jsdom": "^15.2.1", | ||
"kcd-scripts": "^5.0.0" | ||
}, | ||
@@ -59,0 +59,0 @@ "eslintConfig": { |
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
1682207
15395