mswjs / msw

Industry standard API mocking for JavaScript.
https://mswjs.io
MIT License
15.97k stars 519 forks source link

Following React Native docs does not work and Property 'TransformStream' doesn't exist on React Native (runtime) #2367

Open lgibso34 opened 13 hours ago

lgibso34 commented 13 hours ago

Prerequisites

Environment check

Node.js version

v18.15.0

Reproduction repository

https://github.com/lgibso34/react-native-msw

Reproduction steps

Similar to #2344 but not Jest related.

  1. checkout main branch
  2. npm start
  3. launch on device

TransformStream error

1.git checkout bug/sync

  1. npm start
  2. launch on device

Current behavior

Bug 1: Seems that React Native does not support the dynamic import syntax and fails to register the component in time.

Bug 2: Property 'TransformStream' doesn't exist on React Native at runtime running the synchronous code. This would also occur if the async version (bug 1) worked

Expected behavior

Bug 1: I expect the docs to explain how to get this working with additional metro config or a complete example with Metro and RN CLI. I expect the docs to accurately describe how to get msw to work in React Native.

Bug 2: I expect this to work on React Native like the docs suggest.

Async error (main) not_registered

Sync error (bug/sync) TransformStream no exist