Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

77
Views
Using Jest with ReactDOM.findDOMNode

Jest (technically, Jest snapshot testing with ReactTestRenderer) does not work with ReactDOM.findDOMNode.

I've seen where I can work around this using Jest mocks. For example, if my ChannelScanner component uses my RadioButtonSet component, which wraps react-widgets' SelectList, then putting the following code in ChannelScanner.test.js allows snapshot testing to work:

jest.mock('../../src/components/forms/RadioButtonSet', () => 'RadioButtonSet');

However, this seems to break encapsulation: RadioButtonSet's tests have to set up mocks based on the components it uses, and the transitive components that they use, and this work has to be repeated for every component.

What's the best way to handle this? Short of enabling automock, is there a good way to say, "This module knows that it needs to mock itself whenever it appears?"

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!