@testing-library/dom
Advanced tools
Comparing version 7.2.2 to 7.3.0
@@ -27,2 +27,4 @@ "use strict"; | ||
defaultHidden: false, | ||
//showOriginalStackTrace flag to show the full error stack traces for async errors | ||
showOriginalStackTrace: false, | ||
@@ -29,0 +31,0 @@ // called when getBy* queries fail. (message, container) => Error |
@@ -13,5 +13,13 @@ "use strict"; | ||
// This is so the stack trace the developer sees is one that's | ||
// closer to their code (because async stack traces are hard to follow). | ||
function copyStackTrace(target, source) { | ||
target.stack = source.stack.replace(source.message, target.message); | ||
} | ||
function waitFor(callback, { | ||
container = (0, _helpers.getDocument)(), | ||
timeout = (0, _config.getConfig)().asyncUtilTimeout, | ||
showOriginalStackTrace = (0, _config.getConfig)().showOriginalStackTrace, | ||
stackTraceError, | ||
interval = 50, | ||
@@ -24,9 +32,7 @@ mutationObserverOptions = { | ||
} | ||
} = {}) { | ||
}) { | ||
if (typeof callback !== 'function') { | ||
throw new TypeError('Received `callback` arg must be a function'); | ||
} // created here so we get a nice stacktrace | ||
} | ||
const timedOutError = new Error('Timed out in waitFor.'); | ||
if (interval < 1) interval = 1; | ||
@@ -66,3 +72,19 @@ return new Promise((resolve, reject) => { | ||
function onTimeout() { | ||
onDone(lastError || timedOutError, null); | ||
let error; | ||
if (lastError) { | ||
error = lastError; | ||
if (!showOriginalStackTrace && error.name === 'TestingLibraryElementError') { | ||
copyStackTrace(error, stackTraceError); | ||
} | ||
} else { | ||
error = new Error('Timed out in waitFor.'); | ||
if (!showOriginalStackTrace) { | ||
copyStackTrace(error, stackTraceError); | ||
} | ||
} | ||
onDone(error, null); | ||
} | ||
@@ -72,4 +94,10 @@ }); | ||
function waitForWrapper(...args) { | ||
return (0, _config.getConfig)().asyncWrapper(() => waitFor(...args)); | ||
function waitForWrapper(callback, options) { | ||
// create the error here so its stack trace is as close to the | ||
// calling code as possible | ||
const stackTraceError = new Error('STACK_TRACE_MESSAGE'); | ||
return (0, _config.getConfig)().asyncWrapper(() => waitFor(callback, { | ||
stackTraceError, | ||
...options | ||
})); | ||
} | ||
@@ -76,0 +104,0 @@ |
{ | ||
"name": "@testing-library/dom", | ||
"version": "7.2.2", | ||
"version": "7.3.0", | ||
"description": "Simple and complete DOM testing utilities that encourage good testing practices.", | ||
@@ -38,15 +38,15 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@babel/runtime": "^7.9.2", | ||
"@types/testing-library__dom": "^7.0.0", | ||
"@babel/runtime": "^7.9.6", | ||
"@types/testing-library__dom": "^7.0.2", | ||
"aria-query": "^4.0.2", | ||
"dom-accessibility-api": "^0.4.2", | ||
"pretty-format": "^25.1.0" | ||
"dom-accessibility-api": "^0.4.3", | ||
"pretty-format": "^26.0.1" | ||
}, | ||
"devDependencies": { | ||
"@testing-library/jest-dom": "^5.1.1", | ||
"@testing-library/jest-dom": "^5.5.0", | ||
"jest-in-case": "^1.0.2", | ||
"jest-serializer-ansi": "^1.0.3", | ||
"jest-watch-select-projects": "^2.0.0", | ||
"jsdom": "^16.2.1", | ||
"kcd-scripts": "^5.6.0" | ||
"jsdom": "^16.2.2", | ||
"kcd-scripts": "^5.11.1" | ||
}, | ||
@@ -53,0 +53,0 @@ "eslintConfig": { |
@@ -248,2 +248,3 @@ <div align="center"> | ||
<td align="center"><a href="http://kwboyd.com"><img src="https://avatars0.githubusercontent.com/u/13855750?v=4" width="100px;" alt=""/><br /><sub><b>Kate W. Boyd</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=kwboyd" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/rahulchavan30"><img src="https://avatars2.githubusercontent.com/u/5296464?v=4" width="100px;" alt=""/><br /><sub><b>Rahul Suryakanth</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=rahulchavan30" title="Code">💻</a> <a href="https://github.com/testing-library/dom-testing-library/commits?author=rahulchavan30" title="Tests">⚠️</a></td> | ||
</tr> | ||
@@ -250,0 +251,0 @@ </table> |
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
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
2442476
19567
306
+ Added@jest/types@26.6.2(transitive)
+ Added@types/istanbul-reports@3.0.4(transitive)
+ Added@types/node@22.7.4(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedpretty-format@26.6.2(transitive)
+ Addedreact-is@17.0.2(transitive)
+ Addedundici-types@6.19.8(transitive)
- Removed@jest/types@25.5.0(transitive)
- Removed@types/istanbul-reports@1.1.2(transitive)
- Removedchalk@3.0.0(transitive)
- Removedpretty-format@25.5.0(transitive)
- Removedreact-is@16.13.1(transitive)
Updated@babel/runtime@^7.9.6
Updateddom-accessibility-api@^0.4.3
Updatedpretty-format@^26.0.1