Nice example how Javascript can have a unit test with fetch call by mocking.

Unit test for fetch

Guide to testable code