Coder Social home page Coder Social logo

Comments (7)

lilactown avatar lilactown commented on June 21, 2024 1

ebe00d0 allows string keys to be used to pass props to DOM elements verbatim. E.g.

(d/button {"logical-id" "foo"} "Foo")

This will go out in the next release. You're welcome to use it via git deps for now.

However, again, I would strongly encourage you to migrate your tests to use data- attributes, as it is industry best practice to do so and guarantees that your tests won't break in subtle ways later. Assuming this application (and tests) will live on for years, it's probably worth the investment now to do so.

Either way, thanks for the report! I'll close this for now. If you do try out the string keys functionality and you find any bugs, please open another issue.

from helix.

daveyarwood avatar daveyarwood commented on June 21, 2024

Potentially related to #9.

from helix.

lilactown avatar lilactown commented on June 21, 2024

For test IDs and other custom attributes that you don't want to be munged, you can prefix data- to the beginning and it should not be camelCased. E.g.

(d/button {:data-testid "foo-button"} "Foo")

See

(defn camel-case
for reference, above it is a regex with other prefixes that don't get camelCased - at the moment aria- and -- attributes.

Hope that helps!

from helix.

daveyarwood avatar daveyarwood commented on June 21, 2024

In our case, the trouble is that the tests are expecting certain elements to be identified with the property logical-id, not e.g. data-logical-id.

from helix.

lilactown avatar lilactown commented on June 21, 2024

Maybe a silly question, but could you change the tests? AFAIK best practices for DOM testing is to use data- attributes, see https://docs.cypress.io/guides/references/best-practices#Selecting-Elements and https://testing-library.com/docs/queries/bytestid/.

The usage of data attributes for this is to ensure that future changes to the DOM spec don't end up changing the behavior of the elements you've attached the attributes to. See https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes

I can think about other fixes for this, but in general it will behoove you to store and lookup this type of information in data- attributes.

from helix.

daveyarwood avatar daveyarwood commented on June 21, 2024

Thanks for the information, this is helpful!

We would prefer to avoid renaming the attributes, since we are already using the non-data-prefixed version in a ton of places, but we could do it if we have to.

We might also be able to work around this by using non-native elements (e.g. MUI Box), since the properties are passed through unchanged for those.

from helix.

daveyarwood avatar daveyarwood commented on June 21, 2024

That all sounds good - thanks for the fast response!

from helix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.