assert_text("foo")
VS assert_has(Q.text("foo"))
#689
Unanswered
agatheblues
asked this question in
Q&A
Replies: 1 comment
-
@agatheblues Assert_has seems to look at all levels below the parent element that is passed to it but assert_text seems to look within the specific element that is passed to it. I had a test failing because a temporary error banner would pop up in the html. So perhaps assert_has works because it is at a high and general enough level to still include "Foo created successfully" and assert_text was to specific for the change....? Although, assert_text does still work if used at the level of a session. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Issue
Hello! I had a working feature spec for creating a resource. I added a step in the resource creation, enqueuing a worker. Then suddenly the feature spec failed to pass, although the user flow and views are unchanged.
The test would go like this:
and fails on the
assert_text
line with:There's a screenshot output with the failure, that clearly shows that the
"Foo created successfully."
is present on the page. The failure doesn't appear to be flaky as it systematically failed on my branch.A colleague then suggested to change the test to:
...and then the test passed again 🧚♀️ . It passed on the CI and locally, multiple times.
I was not expecting
assert_text
to behave differently thanassert_has
. Do they behave differently? What can explain that one passes and the other not?Note: this is a live view.
Details
Elixir: 1.13.2
Erlang: Erlang/OTP 24
OS: macOs 11.2
Webdriver (selenium, chromedriver, geckodriver, etc): chromedriver
Browser (Chrome, Firefox, Safari, etc): Chrome
Local or CI: both
Test Code & HTML
I can provide more detailed HTML if needed but I'm more looking for an explanation than a solution, if one comes to your mind 🌈
Beta Was this translation helpful? Give feedback.
All reactions