Aurelia DOM events

Unfortunately, Aurelia does not provide a testing mechanism to test DOM events. This means that we cannot easily create a test that enters data into an input field, and then clicks on the Form submit button, as we did with Backbone. Consider the following HTML snippet:

<button id="submit-button-button"  
   class="submit-button"  
   click.delegate="nSubmitClicked()">Submit 
</button> 

Here, we have the HTML snippet that renders our Submit button. We have already seen tests that make sure that this button is rendered onto the screen, and that the name of the button is, in fact, Submit. But take a closer look at the function name for the click.delegate attribute. It contains a very subtle misspelling of the onSubmitClicked function in our View, and is missing the starting "o". If we compile this version of our code, Aurelia will not indicate this error in the build step. It is only at runtime, when we physically click on the button itself that we get a runtime error as follows:

The error that we are seeing is a very simple one to recreate. What this means is that we are not able to unit test the resultant DOM interactions between our rendered HTML, and our Aurelia classes. This lack of unit-testing means that we will need to utilize end-to-end testing using tools such as Protractor to find these sorts of errors within our application, which is a far more expensive exercise than simply writing a unit test.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.37.68