infinitered / ignite

Infinite Red's battle-tested React Native project boilerplate, along with a CLI, component/model generators, and more!
MIT License
17.32k stars 1.37k forks source link

Test proposal for base #83

Closed GantMan closed 8 years ago

GantMan commented 8 years ago

We should add fixtures for our example API, along with a test that verifies the functions available on APIFixtures at least match the functions designated on API live. This helps stop a situation where someone renames or utilizes one and not the other. Result: a large time delay between the dev who worked on a project and maybe even had their PR accepted, and the network error they would cause.

This test is valuable in generated projects.

I'd like to see @fvonhoven implement this. Thoughts welcome @skellock

GantMan commented 8 years ago

FYI, API is hard to bring into mocha tests :( So much stubbing needed.

kevinvangelder commented 8 years ago

@GantMan: @skellock and I came up with a reasonable way to handle this. Basically, we have parallel services, Api which calls the real api and FakeApi which calls the fixtures, and then in our saga index we override any erroring or absent endpoints with the fake method. For testing, we simply load up FakeApi and use it directly. It probably sounds clunky how I've described it, but in action it's actually pretty slick.

GantMan commented 8 years ago

We might need to evaluate react-native-mock which claims to mock RN in entirety.

GantMan commented 8 years ago

Fixtures have been added. This should be very testable now. Let's revisit.