Giter VIP home page Giter VIP logo

Comments (4)

Saadnajmi avatar Saadnajmi commented on June 8, 2024

@chiuam any idea? I think you worked last on the high contrast getter?

from fluentui-react-native.

rurikoaraki avatar rurikoaraki commented on June 8, 2024

Might need a mock - a lot of RN module functionality tends to need to get mocked out. esp if it accesses native info

from fluentui-react-native.

rurikoaraki avatar rurikoaraki commented on June 8, 2024

https://jestjs.io/docs/tutorial-react-native#mock-native-modules-using-jestmock

from fluentui-react-native.

lyzhan7 avatar lyzhan7 commented on June 8, 2024

Think I found a fix for this, which was to make sure the AccessibilityInfo module was not getting mocked out. My working understanding of why this fixed the issue is that the AccessibilityInfo module was getting mocked out automatically (I think because it's a node module, and node modules get mocked out automatically) - but it was getting mocked out incorrectly. When I would try printing out what was in AccessibilityInfo this is what I would get:

{
        addEventListener: [Function: mockConstructor] {
          _isMockFunction: true,
          getMockImplementation: [Function (anonymous)],
          mock: [Getter/Setter],
          mockClear: [Function (anonymous)],
          mockReset: [Function (anonymous)],
          mockRestore: [Function (anonymous)],
          mockReturnValueOnce: [Function (anonymous)],
          mockResolvedValueOnce: [Function (anonymous)],
          mockRejectedValueOnce: [Function (anonymous)],
          mockReturnValue: [Function (anonymous)],
          mockResolvedValue: [Function (anonymous)],
          mockRejectedValue: [Function (anonymous)],
          mockImplementationOnce: [Function (anonymous)],
          mockImplementation: [Function (anonymous)],
          mockReturnThis: [Function (anonymous)],
          mockName: [Function (anonymous)],
          getMockName: [Function (anonymous)]
        },
        announceForAccessibility: [Function: mockConstructor] {
          _isMockFunction: true,
          getMockImplementation: [Function (anonymous)],
          mock: [Getter/Setter],
          mockClear: [Function (anonymous)],
          mockReset: [Function (anonymous)],
          mockRestore: [Function (anonymous)],
          mockReturnValueOnce: [Function (anonymous)],
          mockResolvedValueOnce: [Function (anonymous)],
          mockRejectedValueOnce: [Function (anonymous)],
          mockReturnValue: [Function (anonymous)],
          mockResolvedValue: [Function (anonymous)],
          mockRejectedValue: [Function (anonymous)],
          mockImplementationOnce: [Function (anonymous)],
          mockImplementation: [Function (anonymous)],
          mockReturnThis: [Function (anonymous)],
          mockName: [Function (anonymous)],
          getMockName: [Function (anonymous)]
        },
 ...

It would print a bunch of mocked methods, but not isHighContrast. The list of methods printed out corresponded with the react-native AccessiibilityInfo object (which doesn't include isHighContastEnabled), not the react-native-macos AccessibilityInfo object.

If i printed out AccessibilityInfo while I was running the tester, all the react-native-macos methods would get printed out correctly.

I don't know why AccessibilityInfo was getting mocked out incorrectly, but using the actual module worked.

from fluentui-react-native.

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.