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

Cc/search test #3663

Closed
wants to merge 2 commits into from
Closed

Cc/search test #3663

wants to merge 2 commits into from

Conversation

ChristopherChudzicki
Copy link
Contributor

Pre-Flight checklist

  • Screenshots and design review for any changes that affect layout or styling
    • Desktop screenshots
    • Mobile width screenshots
  • Migrations
    • Migration is backwards-compatible with current production code
  • Testing
    • Code is tested
    • Changes have been manually tested
  • Settings
    • New settings are documented and present in app.json
    • New settings have reasonable development defaults, if applicable

What are the relevant tickets?

(Required)

What's this PR do?

(Required)

How should this be manually tested?

(Required)

Where should the reviewer start?

(Optional)

Any background context you want to provide?

(Optional)

Screenshots (if appropriate)

(Optional)

What GIF best describes this PR or how it makes you feel?

(Optional)

const scroller = results.parentNode
assertInstanceOf(scroller, HTMLElement)
jest.spyOn(scroller, "offsetParent", "get").mockReturnValue(document.body)
}
Copy link
Contributor Author

@ChristopherChudzicki ChristopherChudzicki Aug 1, 2022

Choose a reason for hiding this comment

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

Context: Enzyme gives devs access to the react component itself. So you can do stuff like

// call `loadMore` ourselves
wrapper.get(InfiniteScroller).prop('loadMore')()

react-testing-library doesn't give you direct access to the components (neither does react, at least via its public api; enzyme gives you access to the components vai react internals). RTL's philosophy is usually: do the "real thing" (click a button; type text, etc) and check that your component responds appropriately. In JSDOM environments (like jest) that's particularly hard. RTL's official recommendation would be "use a real browser environment" for this testing-library/react-testing-library#671 (comment)

@ChristopherChudzicki
Copy link
Contributor Author

Superseded by #3669

@rhysyngsun rhysyngsun deleted the cc/search-test branch March 10, 2023 18:52
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.

1 participant