New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functional testing guidelines #9162
Comments
I'm starting to instrument some code with It looked like most of the values used |
@ycombinator Great call. I think the only appropriate use case for hyphens would be if you need to dynamically generate the selector and you don't want to do string manipulation: <div ng-repeat="thing in things" data-test-subj="thingItem-{{:thing.name}}"> |
Confirm success/failure the same way a user wouldFor example, use the presence of a toast (https://github.com/elastic/kibana/pull/15749/files#diff-900adf3e48329f3b99bb703081058de3R327) or a callout (#21250) to verify that the outcome you expected has occurred, whether that outcome is success, failure, or something else. If a toast or callout doesn't exist, then consider adding one. Verify location the same way a user wouldFor example, check the last breadcrumb (#15749) or the page title (#21245) to verify that you've successfully navigated to a location and the UI is ready to be used. Don't assert against complete text contentChecking for full equality with an entire sentence or paragraph is paranoid and brittle. Find the part of that sentence of paragraph which is the essence of that paragraph, e.g. an error code or a noun like "5 visualizations were successfully deleted", and check that the string includes the important substring. This will be more likely to withstand future changes without breaking the test. |
Here's an earlier PR for adding a functional tests README, which contains some useful information on the |
More insight on the best way to interact with the UI here: #21123 (comment) |
Wait until elements have finished animating before interacting with themThis is borrowed from https://medium.freecodecamp.org/how-to-write-reliable-browser-tests-using-selenium-and-node-js-c3fdafdca2a9. In #21302 I kept running into problems where I would try to dismiss a toast by clicking on it, only for the click to silently fail. This was because the toast was still moving when the click was sent, so the click ended up missing. I solved this by waiting for the toast's opacity to be 1 before trying to click it. |
Don't use findDisplayed* methodsThese methods look only for visible objects, which is slower and prone to flakiness. The should really only be used in edge cases where the visibility of an element can’t be ensured in advance. Instead of using |
Based off #9106
Let's create guidelines for how to write good functional tests,
style_guides/functional_test_style_guide.md
.Content
data-test-subj
(Fix bug where the loading indicator was wider than the screen #8854 (comment)).The text was updated successfully, but these errors were encountered: