Skip to content

TypeError: _reactNative.AccessibilityInfo.announceForAccessibilityWithOptions is not a function #44014

@Jonnboy91

Description

@Jonnboy91

Description

When using AccessibilityInfo.announceForAccessibility no problems come when I run jest, but when I change it to AccessibilityInfo.announceForAccessibilityWithOptions I get: TypeError: _reactNative.AccessibilityInfo.announceForAccessibilityWithOptions is not a function
I checked node_modules/react-native/jest/setup.js file I can see that under AccessibilityInfo there is no announceForAccessibilityWithOptions mocking, but when I change announceForAccessibility -> announceForAccessibilityWithOptions in that file then tests run without issues (not going to obviously leave it like this, just tested if that helps).

I tried to mock announceForAccessibilityWithOptions within my own jest.setup file, but that created a lot of different issues.

Steps to reproduce

Use AccessibilityInfo.announceForAccessibilityWithOptions() and run jest and you'll get an issue TypeError: _reactNative.AccessibilityInfo.announceForAccessibilityWithOptions is not a function

React Native Version

0.73.6

Affected Platforms

Build - MacOS

Output of npx react-native info

info Fetching system and libraries information...
System:
  OS: macOS 14.2.1
  CPU: (10) arm64 Apple M2 Pro
  Memory: 613.63 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.11.0
    path: ~/.nvm/versions/node/v20.11.0/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.2.4
    path: ~/.nvm/versions/node/v20.11.0/bin/npm
  Watchman:
    version: 2023.12.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.2
    path: /Users/jonnesten/.asdf/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11076708
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /usr/bin/javac
  Ruby:
    version: 3.2.2
    path: /Users/jonnesten/.asdf/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.6
    wanted: 0.73.6
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

`TypeError: _reactNative.AccessibilityInfo.announceForAccessibilityWithOptions is not a function`

Reproducer

n/a

Screenshots and Videos

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions