Skip to content

[Expo] waitForElement: Promise constructor's argument is not a function #29

@wKovacs64

Description

@wKovacs64

Created a fresh Expo app and tried to use waitForElement, but it throws. Works fine in vanilla RN app.

Test:

it('renders', async () => {
  const { getByText } = render(<App />);

  await waitForElement(() => getByText(/working/));
});

Result:

TypeError: Promise constructor's argument is not a function

     7 |     const { getByText } = render(<App />);
     8 | 
  >  9 |     await waitForElement(() => getByText(/working/));
    10 |   });
    11 | });
    12 | 
    
    at new Promise (node_modules/promise/lib/core.js:59:11)
    at resolve (node_modules/react-native-testing-library/src/waitForElement.js:8:26)
    at Object.getByText (App.test.js:9:32)
    at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:114:21)
    at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
    at invoke (node_modules/regenerator-runtime/runtime.js:152:20)
    at node_modules/regenerator-runtime/runtime.js:195:11
    at tryCallTwo (node_modules/promise/lib/core.js:45:5)

I'm assuming it has something to do with Expo's jest-expo preset, but I haven't narrowed it down yet.

Reproduction repo if anyone wants to mess with it: https://github.com/wKovacs64/rntl-expo-test

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions