Skip to content

Commit

Permalink
[jest] Fix mock-generator crash and update mocks (expo#23062)
Browse files Browse the repository at this point in the history
# Why

In preparation for the SDK 49 release, we should update our jest mocks

# How

Fixed `jest-mock-generator` crash when loading the bundle, updated
`logUrl` to be read from `expoGoConfig` instead of the `manifest` and
followed the steps detailed in [Generating new Jest
Mocks.md](https://github.com/expo/expo/blob/main/guides/Generating%20Jest%20Mocks.md)
to update the mocks

 

# Test Plan

Run `jest-expo-mock-generator` through Expo Go Unversioned 

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).
  • Loading branch information
gabrieldonadel authored Jun 23, 2023
1 parent 3f3c30a commit 4dad52a
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 235 deletions.
4 changes: 2 additions & 2 deletions apps/jest-expo-mock-generator/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ global.performance = {
now: () => 0,
};

const logUrl = Constants.manifest.logUrl;
const logUrl = Constants.expoGoConfig.logUrl;
const sessionId = uuidV4();

const { ExpoNativeModuleIntrospection } = NativeModules;
Expand Down Expand Up @@ -74,7 +74,7 @@ export default class App extends React.Component {
const moduleSpecs = await _getExpoModuleSpecsAsync();
const code = `module.exports = ${JSON.stringify(moduleSpecs, replacer)};`;
await setStringAsync(code);
this.setState({ moduleSpecs });
this.setState({ moduleSpecs: code });
const message = `
------------------------------COPY THE TEXT BELOW------------------------------
Expand Down
4 changes: 2 additions & 2 deletions apps/jest-expo-mock-generator/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const { createMetroConfiguration } = require('expo-yarn-workspaces');
const { getDefaultConfig } = require('expo/metro-config');

module.exports = createMetroConfiguration(__dirname);
module.exports = getDefaultConfig(__dirname);
2 changes: 2 additions & 0 deletions packages/jest-expo/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

### 🎉 New features

- Updated mocks for Expo SDK 49. ([#23062](https://github.com/expo/expo/pull/23062) by [@gabrieldonadel](https://github.com/gabrieldonadel))

### 🐛 Bug fixes

### 💡 Others
Expand Down
Loading

0 comments on commit 4dad52a

Please sign in to comment.