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

Allow running in node environment #64

Merged
merged 1 commit into from
Oct 9, 2018
Merged

Conversation

sheerun
Copy link
Contributor

@sheerun sheerun commented Oct 8, 2018

Fixes #58

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change 👍 Impressive!

@gnapse
Copy link
Member

gnapse commented Oct 9, 2018

This is awesome. Thanks! 👏👏👏

@gnapse gnapse merged commit 86ee9b1 into testing-library:master Oct 9, 2018
@gnapse
Copy link
Member

gnapse commented Oct 9, 2018

🎉 This PR is included in version 2.0.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

!(htmlElement instanceof SVGElement)
!htmlElement.ownerDocument &&
!(htmlElement instanceof htmlElement.ownerDocument.HTMLElement) &&
!(htmlElement instanceof htmlElement.ownerDocument.SVGElement)
Copy link
Member

@gnapse gnapse Oct 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this condition be this instead?

  if (
    !htmlElement.ownerDocument ||
    (
      !(htmlElement instanceof htmlElement.ownerDocument.HTMLElement) &&
      !(htmlElement instanceof htmlElement.ownerDocument.SVGElement)
    )
  ) {
    throw new HtmlElementTypeError(htmlElement, matcherFn, context, validTypes)
  }

If there's no htmlElement.ownerDocument, it makes no sense to go and evaluate the rest of the condition, because the rest of the conditional depends entirely on htmlElement.ownerDocument not being undefined.

Please, let me know if I'm correct or not so far. If I am, I have more things to say, but I wanted to confirm up to this point at least

cc @sheerun

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, here it is the additional part of what I wanted to say.

I think the above is never surfaced because checkHtmlElement is coincidentally always called with a valid html element that has an ownerDocument.

So we never really get to the point where the instanceof parts of the conditions are evaluated even. The thing is, when I fixed the condition locally, I get that htmlElement.ownerDocument.HTMLElement is undefined. The same with SVGElement.

This is the point where I'm no longer sure how to continue this fix. Care to chime in @sheerun?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More insight into this. Code coverage is not at 100% for this src/utils.js file. However, I'm not sure how that's not being captured by the travis build, which has always flagged code coverage less than 100%.

😕

@gnapse
Copy link
Member

gnapse commented Oct 17, 2018

@sheerun any comments on my concerns above?

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

Successfully merging this pull request may close these issues.

3 participants