Stubbing a React component is easy with Sinon.


default(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null

Importing the component to stub and stubbing it in the before hook.

Example code that causes the above error:

import sinon from 'sinon';
import * as ToStubComponent from './to-stub-component';

describe('....', function () {
    sinon.stub(ToStubComponent, 'default').returns(<div/>);
  it('my test', ...);


The issue from what I can tell is React is trying to execute the component as a class component and there is no render method available. This can be solved by stubbing as a string.

sinon.stub(ToStubComponent, 'default').value('div');