I am given the task to build a test suit using testcafe and, as I write tests I stumble upon one particular question “how much assertions is too much?”. Basically, after the tests are done, a report is generated. Looking at the report it is not intuitive. For example, If an element is not found on the webpage, I’ll see something like:
>Selector('tads') does not exist in the DOM.
This forces me to go through the test manually to verify what failed.
According to the testcafe documentation, you can add an optional message to the assertion. as seen here
As of right now, I have assertions with some messaging in a few places. Would it be wise to have an assertion(with a concise error message) after every click or every action? (i.e. click the login button, do an assertion to see if the login modal appears. Now login, assert that the login modal disappears)
The code would look something like this:
await t.click(this.loginButton);
await t.expect(this.loginButton.exists).ok("I don’t see the login button");
await signup.newUserSignUp();
await t.expect(this.loginButton.exists).notOk("The login modal didn’t disappear");
any feedback would be awesome.