How do we simulate user behavior in automated tests?

Question

With automating tests for our web applications, how do we simulate a user interacting with the application?

Answer

The response to this question reiterates a good practice we’ve come across already: carefully organizing the content and styling of our web apps using classes and ids. By organizing our applications in this way, the portions of the app that our users should interact with, or that change due to user interaction, will be carefully labeled so that we can seamlessly interact with these aspects directly from JavaScript. Because our tests will also be written in JavaScript, it’s mostly trivial to simulate user actions by checking the values within and/or inserting new values for these labeled ascpects of the app.

5 Likes

image

I’m pretty sure that isn’t the expected behavior of the test command…

At first I was thinking the same thing,
although I believe it is telling us the entirety of the test did not succeed since we got:

[phantomjs #0-0] 2 passing (4s)
[phantomjs #0-0] 4 failing

I am getting a line at the very end, though:

npm WARN Local package.json exists, but node_modules missing, did you mean to install?

I’m pretty sure that the Bash console provided should not output that command, ideally?