Giter Site home page Giter Site logo

Comments (4)

RealOrangeOne avatar RealOrangeOne commented on August 19, 2024

Whenever i've been working with sinon, i've had no problem mocking out window. Personally I use jsdom to mock it, and then grab the window out of that. If the mock is an actual mock of window, and not something you make up, it should work fine with most libraries

from react-native-mock.

chrissloey avatar chrissloey commented on August 19, 2024

Thanks for the tip! It looks like jsdom doesn't implement cancelAnimationFrame, but I got things working by using jsdom and stubbing cancelAnimationFrame on top of it.

This still feels like a problem with react-native-mock though - I can submit a PR if you have a preference for fixing it. I think it should just be removed but if there's a reason it's there, there should at least be some docs around it or even a stub for cancelAnimationFrame to prevent exceptions.

from react-native-mock.

RealOrangeOne avatar RealOrangeOne commented on August 19, 2024

I like the idea of fixing it, but I think having jsdom in the project too is a little much, considering others may want a different approach. I think the best solution would be validating that the function is actually there: if (window && window.cancelAnimationFrame) ...?

from react-native-mock.

chrissloey avatar chrissloey commented on August 19, 2024

Agreed on jsdom. After my last comment I realised the code as it is (with reference to window) is straight from React Native's AnimatedImplementation so probably fair to leave it there and guard it as you suggest.

Will submit a PR later today. I have some other Animated related things I'm mocking that I'll submit a PR for separately too.

from react-native-mock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.