Skip to content

Commit

Permalink
Use a fake JSON server to mock File Upload Wizard API in JS unit tests
Browse files Browse the repository at this point in the history
Normally we'd be mocking the web client library, but the two libraries I've tried
are not reliable.

axios-mock-adapter simply doesn't work with it succumbing to this issue:
ctimmerm/axios-mock-adapter#116 (comment)
Tried everything there, no success.

Moxios, is the one I've first chosen and used in previous commits. It's older,
not updated in years and more problematic is that it's prone to "heisenbugs", i.e:
randomly breaking for no obvious reason.

I haven't tried jasmine-ajax, but I figured it's much more time-effective and reliable
to fake the API instead (we are talking about unit tests here, so they should be isolated
from the real implementation). Bonus point is that we can use the fake API to test
and prototype API endpoints with sample data before implementing for real (and thus
being able to try multiple designs).

In the future, we should revisiting the async mocking libraries as that's the long-term proper practice.
  • Loading branch information
Rija Menage authored and rija committed Sep 27, 2020
1 parent 2c32c78 commit 2697ca1
Show file tree
Hide file tree
Showing 5 changed files with 1,445 additions and 7 deletions.
Loading

0 comments on commit 2697ca1

Please sign in to comment.