Quantcast
Channel: Jest - Mock a function getting imported in a component file you're testing - Stack Overflow
Browsing all 2 articles
Browse latest View live

Answer by slideshowp2 for Jest - Mock a function getting imported in a...

You can use jest.spyOn(object, methodName) method, here is a completed demo: idnex.tsx: import React, { Component } from 'react'; import { someHelper } from './utils'; class SomeComponent extends...

View Article


Jest - Mock a function getting imported in a component file you're testing

I have a class component that I want to test using jest. That component is using a function getting imported from a utils file. How do I mock that imported function from my main test file?

View Article

Browsing all 2 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>