question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

utils/bind-data-test-attributes: Handle failing `set()` with assert instead of warning

See original GitHub issue

Reference 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:closed
  • Created 5 years ago
  • Comments:18 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
Turbo87commented, Dec 10, 2018

We could add a supportsDataTestProperties property that a) will disable the tagName == '' 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 😉

0reactions
marcoowcommented, Dec 13, 2018

🤦‍♂️ 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 pass data-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.

export default Component.extend({
  tagName: '',
  data-test-attr: null,
  …
});
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found