Flask has great documentation for testing server side code (currently available here: https://flask.palletsprojects.com/en/1.0.x/testing/). However, for many of my projects, this is only half the picture. Testing requires covering both the client and server code to encapsulate one potential task.
For example, imagine testing a search feature, where search results are obtained through a ajax call. With the documented method, we insert some mock data into a DB, simulate a ajax call to a flask route which we expect to match one or more results, and check that the results are in the returned JSON. However, this is missing some critical points of failure. What it should really look like is: insert some mock data into a DB, GET request the search page, simulate typing a query in the search box, validate that one or more matching results are generated as elements in the search page HTML somewhere.
The thing that comes to mind is to just write all tests in a simulator such as selenium-browser, which should cover basically all of the code used in this process. However, I have never seen this recommended so I am wondering if there is some kind of more standard method used? Is there some more fundamental reason why the client side code is often not spoken of during testing?
Aucun commentaire:
Enregistrer un commentaire