buildkite / frontend

🌏 The front-end application code for https://buildkite.com
MIT License
137 stars 27 forks source link

JS graph/relay UI tests #745

Closed plasticine closed 5 years ago

plasticine commented 5 years ago

screen shot 2018-12-17 at 1 50 31 pm

This was a bit of a late-last-week and bit-of-weekend hack that I demoed a while back and only just finished up.

This PR plumbs things together so that we can write pretty nice, succinct UI units tests against mocked out GraphQL responses. Unlike traditional static mocks or fixtures that can get out of data, this mocking is performed in a pretty unique and awesome way that leverages the fact that the GraphQL schema is vendored in the project, and is typed. This means that mocks will always match the blessed shape of the backend. It also adds a few pretty basic proof-of-concept tests.

Check out the implementation of the mocking test helper, and an example of it in use to get an idea of how this can be used.

I can’t see us writing heaps of these tests, but I think this still going to be an incredibly useful tool for us to avoid having to lean too heavily on expensive and fragile browser tests.