Sign in

Welldone Software
The Best Software Solutions Company

Mocking function calls within a module

JEST logo
// f.jsexport function b(){
return 'b';
export function a(){
return b();

The Naive Approach

test('a', () => {
const f = require('./f');
jest.spyOn(f, 'b').mockReturnValue('c'); expect(f.a()).toBe('c');
// expected 'c' got 'b'

Solution 1 — Splitting The Module Into Different Files

Sometimes we respond to React element mounts. The first instinct is to useRef & useEffect. But It’s wrong. What you really need is often useCallback.

setRef returned from useCallback

How can you run tests on version X and version Y of a library, with real-world examples of testing React 16 and React 17

React.memo / React.PureComponent usage guide

What’s a Pure Component?


What is issue #14099 in React’s repo and how it affects you?

Why do we need useCallback in the first place?

A naive code where a pure heavy component is re-rendered on every re-render of its parent.

When working remotely, you benefit much more from good working processes and proactive team members and you are punished much more severely for sloppy work processes and personal carelessness

TypeScript support, Custom hooks tracking (like React-Redux’s useSelector), Tracking of all pure components.

TypeScript Support

Improved Overall Stability

Tracking of all Pure Components

How does React work?

const App = () => {
const [counter, setCounter] = useState(0);
return (
<button onClick={() => setCounter(counter + 1)}>Counter</button>
<Component1 />…

Welldone Software

The Best Software Solutions Company

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store