hackgvl / open-map-data-multi-layers-demo

A bookmarkable map displaying all layers from HackGreenville Labs' Open Map Data
https://hackgvl.github.io/open-map-data-multi-layers-demo/
MIT License
2 stars 2 forks source link

Mock API Responses in Vitest Unit Test Suite using Talkback #13

Closed ThorntonMatthewD closed 12 months ago

ThorntonMatthewD commented 12 months ago

Note: This is half of what is needed to address #4. Getting this to mesh with Cypress is taking some tinkering.

Summary

The changes contained in this PR introduce usage of the talkback for use with the unit test suite. Any requests made to https://data.openupstate.org will be proxied via http://localhost:9090 where a talkback server is started automatically upon initiating a run of tests. Talkback will look to see if it has a response "on file", or recorded, in what it calls a "tape" for any request made and hand it up to the item under test if it does come up with one. If one doesn't exist, then it will record the response and similarly make it available to any item looking for it.

Test Plan

  1. Execute npm run test:unit:dev and ensure that the test suite runs.
    1. Since the tapes are checked into source control you shouldn't be making any requests out to the OpenData API. Feel free to utilize Wireshark or any network monitoring tools you have available to confirm this.
  2. Delete the src/tests/tapes folder and rerun the tests. It should be created, and the tapes should be repopulated.
  3. Execute OVERWRITE_TAPES=1 npm run test:unit:dev. This will overwrite any existing tapes. You can confirm this using date -r <path to file> and comapring the before and after timestamps of modification.
oliviasculley commented 12 months ago

@all-contributors add @ThorntonMatthewD for code test

allcontributors[bot] commented 12 months ago

@oliviasculley

I've put up a pull request to add @ThorntonMatthewD! :tada:

ThorntonMatthewD commented 12 months ago

This all looks great! I think some commits could probably get squashed together, but thank you for helping out with this issue!!

Oh wow, yes. I apologize for the spam!

ThorntonMatthewD commented 12 months ago

This all looks great! I think some commits could probably get squashed together, but thank you for helping out with this issue!!

Oh wow, yes. I apologize for the spam!

Thank you for helping me mop up!

oliviasculley commented 12 months ago

@all-contributors Add @ThorntonMatthewD as a contributor for code, test

allcontributors[bot] commented 12 months ago

@oliviasculley

@ThorntonMatthewD already contributed before to code, test