Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New lines are breaking the tests. #636

Closed
betovelandia opened this issue Oct 18, 2016 · 3 comments
Closed

New lines are breaking the tests. #636

betovelandia opened this issue Oct 18, 2016 · 3 comments

Comments

@betovelandia
Copy link

betovelandia commented Oct 18, 2016

Hey guys, so when I look for an element that is in the tree this way:

expect(instance.containsMatchingElement(<a> All Operations </a>)).toBe(true);

This works just fine on this structure:

<li>
  <a> All Operations </a>
</li>

But it fails on this one (notice the new lines):

<li>
  <a>
    All Operations
  </a>
</li>

Just because of the new lines, this shouldn't be happening right?, maybe I'm doing something wrong ?

@blainekasten
Copy link
Contributor

since this API is meant to be matching and not a direct reference, I would assume this shouldn't break it. I don't see any good in it breaking a test. So, seems like a bug to me.

@betovelandia
Copy link
Author

Hi, any updates on this ?

@nfcampos
Copy link
Collaborator

nfcampos commented Apr 1, 2017

@betovelandia to clarify, if your test cases are exactly the JSX elements you originally posted I believe it doesn't work because the first case has leading and trailing spaces around the text and the second one doesn't, see http://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=latest%2Creact%2Cstage-2&targets=&browsers=&builtIns=false&experimental=false&loose=false&spec=false&code=var%20leadingSpace%20%3D%20%3Cli%3E%0A%20%20%3Ca%3E%20All%20Operations%20%3C%2Fa%3E%0A%3C%2Fli%3E%0A%0Avar%20newLine%20%3D%20%3Cli%3E%0A%20%20%3Ca%3E%0A%20%20%20%20All%20Operations%0A%20%20%3C%2Fa%3E%0A%3C%2Fli%3E%0A%0Avar%20noLeadingSpace%20%3D%20%3Cli%3E%0A%20%20%3Ca%3EAll%20Operations%3C%2Fa%3E%0A%3C%2Fli%3E&playground=true for comparison of the compiled output of the two cases

can you confirm whether this is indeed the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants