utils/bind-data-test-attributes: Handle failing `set()` with assert instead of warning
See original GitHub issueReference Commit
After experiencing some issues after trying to add a data-test-selector to tagless components, I realized afterwards, by looking at the commit on master, that a warning was created to give some information. This is a great idea, but maybe not explicit enough (I didn’t see this warning, in the middle of other warnings).
If you agree, I can make a PR to make an assert
instead of a warn
, to be more explicit and to force the user to fix it as soon as this is done. What do you think?
Issue Analytics
- State:
- Created 5 years ago
- Comments:18 (18 by maintainers)
Top Results From Across the Web
utils/bind-data-test-attributes: Handle failing `set()` with assert ...
On first glance it seems fine to make this an assert instead of a warn . I couldn't really think of a scenario...
Read more >Expected Failures | Apple Developer Documentation
Configure your test to handle an expected assertion failure by calling ... Xcode marks the test as an expected failure instead of a...
Read more >Warnings instead of errors from assert_that()? - Stack Overflow
I created a user defined function which accepts a string corresponding to an expression against which you would like to run validate_that() ......
Read more >Python's assert: Debug and Test Your Code Like a Pro
In Python, assertions are statements that you can use to set sanity ... You can use pytest.raises() to handle code that is expected...
Read more >More Assertions
A test is considered successful only if none of its assertions fail during its execution. Note: SUCCEED() is purely documentary and currently doesn't ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We could add a
supportsDataTestProperties
property that a) will disable thetagName == ''
check and b) will be removed by an AST transform so that it doesn’t exist in prod builds. If we do that we wouldn’t even need to revert the current behavior and could keep using assertions, and we could adjust the assertion message to hint about this workaround. PRs welcome 😉🤦♂️ looking at #291 I realize there’s another case where you use a non-Glimmer component with
tagName
and still want to be able to passdata-test-
etc. to forward those to child components. I guess we could change the assertion so that it checks whether the attributes are present on the prototype first before triggering the warning?So if you explicitly defined the attributes you could opt-in to accepting
data-test-
attributes without triggering the warning, e.g.