vendredi 5 mars 2021

Mock Realm interface and functions in React Native

I am currently testing a component that consumes results(Salaries) returned by Realm database and sort them as follows using sorted function from Results interface defined in Realm itself.

salaries.sorted('timestamp', true)[salaries.length - 1].pop

When i run tests it gives the following error :

TypeError: salaries.sorted is not a function

Which makes sense as sorted is not mocked in tests.

I found a mocking module for realm database here but has partial implementation of it. Any help would be appreciated. Thanks.

Aucun commentaire:

Enregistrer un commentaire