Assert that the page shows, or does not show, a message of a kind: an alert box of the page (the notifications at its top, the error box of an error page, an alert of a dialog), an error under a field of a form, or a toast the page showed (a toast closes by itself; the step reads it after it did). A box that lists several lines is read line by line; a line matches when it starts with the text.
Examples
Then I should see the error message "Your login info may be incorrect. Please try again."
Then I should see the success message "Post added."
And I should see the information message "There are no discussion topics yet in this forum."
Then we should not see the error message "Access denied"
Then I should see the warning message "Guests cannot access this course. Please log in."
Pattern
Then(/^(I |we )*should( not)* see the (error|success|warning|information) message "([^"]*)"$/, …)
Part of @webship-js/moodle-steps (github.com/webship/moodle-steps), a step pack for Webship-js 2.0.x.