Enzyme: is ":not" selector not supported?

Created on 14 Jun 2016  路  7Comments  路  Source: enzymejs/enzyme

What I understand is that ":not" is a css selector to find an element without specified attribute.
So, with this component:

const Table = () => (
  <table>
    <thead>
      <tr>
        <th></th>
        <th></th>
      <tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row"></th>
        <td></td>
      <tr>
    </tbody>
  </table>
);

But why this is happening?

wrapper.find('th[scope="row"]').length // == 1
wrapper.find('th:not([scope="row"])').length // == 0 ?
help wanted

Most helpful comment

You can see enzyme is supporting CSS selectors in the following.

https://github.com/airbnb/enzyme/blob/master/docs/api/selector.md#1-a-valid-css-selector

All 7 comments

You can see enzyme is supporting CSS selectors in the following.

https://github.com/airbnb/enzyme/blob/master/docs/api/selector.md#1-a-valid-css-selector

We'd gladly accept a PR if you were wanting to add support for the :not selector!

I'm giving it a try, I'll ley you know soon of my progress!

I've sent the pull request. Can you check it?

This was added in #460.

Looks like the PR referenced above ended up getting closed rather than merged.

For anyone else ending up here from Google, here's the documentation for the implemented solution:
https://airbnb.io/enzyme/docs/api/ShallowWrapper/not.html

@akegan it ended up moving to #1086, and should be in all versions of enzyme 3.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benadamstyles picture benadamstyles  路  3Comments

AdamYahid picture AdamYahid  路  3Comments

abe903 picture abe903  路  3Comments

rexonms picture rexonms  路  3Comments

ivanbtrujillo picture ivanbtrujillo  路  3Comments