@testing-library/dom
Advanced tools
Comparing version 8.11.3 to 8.11.4
@@ -31,3 +31,3 @@ "use strict"; | ||
} else { | ||
return matcher.test(normalizedText); | ||
return matchRegExp(matcher, normalizedText); | ||
} | ||
@@ -47,3 +47,3 @@ } | ||
} else if (matcher instanceof RegExp) { | ||
return matcher.test(normalizedText); | ||
return matchRegExp(matcher, normalizedText); | ||
} else { | ||
@@ -81,11 +81,3 @@ return normalizedText === String(matcher); | ||
}) { | ||
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 { | ||
if (!normalizer) { | ||
// No custom normalizer specified. Just use default. | ||
@@ -97,2 +89,20 @@ return getDefaultNormalizer({ | ||
} | ||
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; | ||
} | ||
function matchRegExp(matcher, text) { | ||
const match = matcher.test(text); | ||
if (matcher.global && matcher.lastIndex !== 0) { | ||
console.warn(`To match all elements we had to reset the lastIndex of the RegExp because the global flag is enabled. We encourage to remove the global flag from the RegExp.`); | ||
matcher.lastIndex = 0; | ||
} | ||
return match; | ||
} |
{ | ||
"name": "@testing-library/dom", | ||
"version": "8.11.3", | ||
"version": "8.11.4", | ||
"description": "Simple and complete DOM testing utilities that encourage good testing practices.", | ||
@@ -29,2 +29,3 @@ "main": "dist/index.js", | ||
"format": "kcd-scripts format", | ||
"install:csb": "npm install", | ||
"lint": "kcd-scripts lint", | ||
@@ -31,0 +32,0 @@ "setup": "npm install && npm run validate -s", |
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
2493939
22062
384