FujoWebDev / AO3.js

NodeJS API for scraping AO3 data
MIT License
15 stars 8 forks source link

Use Mock Service Worker to avoid networks calls to AO3 during tests #16

Closed essential-randomness closed 2 years ago

essential-randomness commented 2 years ago

See: https://mswjs.io/

From the discord discussion:

ms boba — Today at 12:23 PM so basically you would not change anything in the code really, but in the tests you would say "if there is a request for e.g. /works/1234 return test_data/works_1234.html" it means the tests don't ever really use the network then you can have a second test that we just run e.g. on PR submission/once a day that tries to actually fetch the real /works/1234 and checks that it's equal to test_data/works_1234.html. this way running tests becomes much faster, but also we can still be notified of changes

I can take care of this at some point, but I am also very willing to guide someone in setting up MSW, and getting this to work.

essential-randomness commented 2 years ago

Might fix #13

jakehamilton commented 2 years ago

Added a PR for this at #19 :D