Cypress is one of the easiest ways to test your Angular application. But because it is not tied to any Angular API it is hard to look "under the hood" of your tested app. However directly manipulating the internal State of it can make testing even easier. This gist will show you a way to achieve this.
Unfortunately, we need to write a bit of overhead into our Application, this is marginal though.
To write a binding for Cypress we need to create a function that needs to be called in the constructor of each of our Akita Queries. Make sure to pass the query itself to it using this
. Cypress provides a global window.Cypress
variable we can use todetermine whether we are in a Cypress testing environment.
cypressBinding.ts
: