понедельник, 26 октября 2020 г.

Angular Back-end, web-api in the memory

 Angular has very good documentation with a good example. A library helps to run the real application as a tutorial without a server. The library is in-memory-web-api. It looks like a ready solution. It is a great idea. But it has been done specifically for the tutorial. There are cases where we work off-line. So I investigate the case. This is a standard case for Progressive Web Applications(But not this time). In this case,  we have some extra logic for off-line behavior. There are three different variants:



 Variant is (Figure A) a common working variant. Sometimes a case appears when an application has to work without the server for some reason. To test application while the server is not available or is not ready yet for some other reasons. For unit testing, we can use request mocking,  where a possibility exists to separate into different levels hiding into containers. According to the environment, it is possible to inject different services. Any mock logic can be injected. This approach affects the system and messes the architecture (Figure B). The library In memory web API has been implemented for the angular guide(in-memory-web-API). It has a very good idea but also some limitations because it was created specifically for the guide. The idea is to intercept all HTTP requests and mock them (Figure C). This idea helps us to create a whole module for the testing reason that does not work directly with front-end logic and can be disabled and removed easily or switched simply.

An example of the implementation you can find at my investigation repository.

The idea is still in development.


Комментариев нет:

Отправить комментарий