flowjs / flow.js

A JavaScript library providing multiple simultaneous, stable, fault-tolerant and resumable/restartable file uploads via the HTML5 File API.
Other
2.96k stars 346 forks source link

Question: how to handle "Cannot create element with data-test" when testing? #289

Closed DnEgorWeb closed 4 years ago

DnEgorWeb commented 4 years ago

I am using flow with react-native and my components have data-test properties for test purposes.

<TouchableOpacity data-test="touchableOpacityTestId">
  ...
</TouchableOpacity>

And when I run flow I get multiple errors like "Cannot create TouchableOpacity with data-test because data-test is missing in TouchableOpacity". Test itself works ok. I also tried it with testID - no errors then, however in this case for some reason enzyme finds a lot of nodes (this testID is absolutely unique and exists only for one node).

const touchableOpacity = wrapper.find({ testID: 'AboutUs_TouchableOpacity' });
touchableOpacity.props().onPress();

And I get this error: Method “props” is meant to be run on 1 node. 4 found instead.. If I replace testID with data-test or any other name it works fine, except that flow fails.

command-tab commented 4 years ago

I think perhaps you meant to open this issue in https://github.com/facebook/flow