Automatic testing of Single Page Web Application



  • I have a very complex SPA made up of a client that uses AJAX to make calls, and a rather large number of endpoints that respond to REST requests. We are writing tests the "classic" way; however, one of the ways we are exploring is:

    • We use the app doing a set of tasks so that we cover 100% of the use
    • The browser (an extension?) records all of the ajax calls, and all of the responses
    • Some kind of data file is created with the requests and the exact responses
    • A server-side script that will emulate all of the requests and check that the responses match

    I realise that if the data structure changes, the data will be outdated.

    Is there anything like this out there? Or is it really a matter of writing everything by hand?



  • data structure changes, the data will be outdated

    Yes, and the failure shows that your frontend application is no longer compatable with the service.

    The problem is that you are mixing semantic checking and syntax checking.

    Semantic validation of a service is done by the service itself - a service knows about the business rules and entities it manipulates: And these are of no concern of the external world.

    What concerns the external world is the interface the service provides: What format of input does the service expect? What format of output does service provide?

    Here we have to check the syntax of the input and output. It is also known as Contract Testing:

    Contract testing ensures that a pair of applications will work correctly together by checking each application in isolation to ensure the messages it sends or receives conform to a shared understanding that is documented in a "contract".

    Maybe your tech stack provides Contract Testing options.

    Alternatively, you can check out Pact.io

    enter image description here


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2