-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check if requestAnimationFrame is defined in shouldUpdate #81
Conversation
src/setRafTimeout.js
Outdated
@@ -10,7 +10,7 @@ export default function setRafTimeout(callback, timeout = 0) { | |||
callback(now); | |||
currTime = -1; | |||
} else { | |||
requestAnimationFrame(shouldUpdate); | |||
if (typeof requestAnimationFrame !== 'undefined') requestAnimationFrame(shouldUpdate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doing typeof requestAnimationFrame !== 'undefined'
for the conditional because using !requestAnimationFrame
as the conditional still caused the undefined error. This ensures that we check without throwing an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM although can't you just check for a falsy requestAnminationFrame instead of type of?
Hey @ckifer ! Do you mean something like if (!requestAnimationFrame) { ... } Typically wouldn't do the whole |
Weird yeah the second way is what I was thinking should work? Strange... generally I would think libraries shouldn't have to adjust for a test framework but.. makes sense I guess? |
Yeah.. It was really bizarre. I think it's all related to VItest interacting with the react-testing-library which leads to fake timers not working: testing-library/react-testing-library#1198 When making the tests async, stuff just didn't want to behave nicely for the animated tests, and the library would still be calling |
JsDom in general is probably a lot of the issue because everything animation and actual dom testing wise needs to be mocked |
Updated tests to pass using Vitest. This PR depends on a [change in the react-smooth](recharts/react-smooth#81) library to deal with the unhandled exceptions we receive in the tests. vitest-dev/vitest#3117 Additional changes: - updated the test command to not watch by default. This is to prevent pushes from being stuck due to running the test in watch mode for the push husky checks. - turned off the no-extraneous-dependencies error so that we no longer receive errors when importing `vitest`. - have Vitest ignore `node_modules` and `react-smooth` tests. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Nikolas Rieble <nikolas.rieble@tulip.co> Co-authored-by: “Nikolas <“nikolas@rieble.com“> Co-authored-by: Pavel Vaněček <corkscreewe@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Hong Seungwoo <qksn1541@gmail.com> Co-authored-by: Coltin Kifer <ckifer@amazon.com>
Fixes test issues with Vitest in Recharts