-
-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: throw and suggest a URL polyfill for React Native (#1520)
- Loading branch information
1 parent
2ae9fa9
commit b4ac829
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { invariant } from 'outvariant' | ||
import { devUtils } from './devUtils' | ||
|
||
export function checkGlobals() { | ||
/** | ||
* MSW expects the "URL" constructor to be defined. | ||
* It's not present in React Native so suggest a polyfill | ||
* instead of failing silently. | ||
* @see https://github.com/mswjs/msw/issues/1408 | ||
*/ | ||
invariant( | ||
typeof URL !== 'undefined', | ||
devUtils.formatMessage( | ||
`Global "URL" class is not defined. This likely means that you're running MSW in an environment that doesn't support all Node.js standard API (e.g. React Native). If that's the case, please use an appropriate polyfill for the "URL" class, like "react-native-url-polyfill".`, | ||
), | ||
) | ||
} |