I may have missed an explanation in #70 but I expected this selector to work:
.find('a[href='http://example.com/xyz']')
But instead it complains:
TypeError: Enzyme received a complex CSS selector ('a[href='http://example.com/xyz']') that it does not currently support
If I remove the domain name from URL and make it relative, it works:
.find('a[href='/xyz']')
It gives no error and works as expected.
Hmm. This is an unfortunate side effect of the shitty CSS parsing we are doing.
An alternative for you right now is to do: .find({ href: url }) instead of the stringified CSS selector.
also experiencing this with a selector as follows:
find('img[src="http://image.com/image.jpg"]')
@lelandrichardson is there a long-term plan for how you guys want to approach CSS selector parsing? Maybe something that returns an AST for selectors?
An update on this?
@stevenmusumeche our CSS parsing is still not great, we're tracking it and hope to implement an actual CSS parser soon. Until then I'd recommend the workaround that @lelandrichardson mentioned:
An alternative for you right now is to do: .find({ href: url }) instead of the stringified CSS selector.
+1
This will be resolved by https://github.com/airbnb/enzyme/pull/1086
Closed in #1086
Most helpful comment
Hmm. This is an unfortunate side effect of the shitty CSS parsing we are doing.
An alternative for you right now is to do:
.find({ href: url })instead of the stringified CSS selector.