0

I'm using the react-native-code-push codePush HOC, and running some logic in response to a codePushStatusDidChange event hook, in particular, when the status is SyncStatus.UPDATE_INSTALLED.

I haven't had luck finding out whether there is a way to emulate code push events when running in dev mode, to verify that our code is responding properly to the event hook. Is this possible, or is it necessary to release new versions to the code push server?

Side question: if the installMode is set to codePush.InstallMode.ON_NEXT_SUSPEND, is the event hook supposed to receive a SyncStatus.UPDATE_INSTALLED on the next restart? (I suppose once I can get the first question figured out, I can answer the second one on my own!).

twelve17
  • 688
  • 8
  • 20

1 Answers1

0

@twelve17 Hi. I can share my experience regarding testing & CodePush usage. We have both e2e tests (detox + jet) and unit tests (react-native-test-utils + jest). When we run our e2e tests we specify the environment and switch codePush setting in the root HOC:

checkFrequency: isTest()
    ? codePush.CheckFrequency.MANUAL
    : codePush.CheckFrequency.ON_APP_START,

In this case (manual check & update), codePush doesn't do anything while the app is running. It works fine with e2e testing because you really don't need any codePush tasks while running them, definitely.

Regarding unit tests: we don't test the HOC itself (for now), we've just covered only some stateless components, so here I can only recommend you either skip such tests (because codePush is the 3rd-party lib) or write your own wrapper for any of its commands and mock/stub them in case of tests are running.

Community
  • 1
  • 1
styleofspur
  • 123
  • 2
  • 11