Skip to content

Latest commit

 

History

History
67 lines (39 loc) · 3.04 KB

File metadata and controls

67 lines (39 loc) · 3.04 KB

👀 See comment on top of file for template.

I want to write a test.

We use @testing-library/react-native and our helper renderWithWrappersTL. We try to use testID to find elements.

Links:

I want to write a test with relay.

Similar to above. For relay testing we use mockEnvironmentPayload to mock the most recent operation. Look at https://github.com/artsy/relay-workshop for a great tutorial of how we use relay and test with it.

Links:

I want to add some global state, doesn't need to be persisted.

We use easy-peasy for global state, and for non-persisted state we use something called sessionState. This can be in any model. If your global state is something small, you could add it in GlobalStoreModel.ts as part of the sessionState there, or you could create a new Model like ToastModel.ts that only uses non-persisted state, therefore only sessionState.

Links:

I want to add some global state, should be persisted.

Similar to above, but if we want to persist, we put our state outside the sessionState. If your state fits in one of our existing Models in lib/store, you can use that. If it's a separate enough thing, then you can add a new Model, the VisualClueModel.ts is a good example. The state in that model will be persisted.

When changing/adding/removing persisted state, you must create a migration! For more info, look for a migration example in this file, and look at the adding_state_migrations.md docs.

Links:

I want to add a migration for changed/added/removed global state.

Global state that is persisted needs migrations when you change/add/remove anything. That's so that the app can do any necessary preparation to the persisted storage then the app is launched, to make sure the app is in a consistent state.

There is documentation in adding_state_migrations.md, but here are the main steps are:

Links: