Skip to content

TestUtils cannot render stateless function components #5901

@ibrown-gaikai

Description

@ibrown-gaikai

I'm using react 14.3, babel 6.0.15 and react test utils addon 0.14.6 . Jasmine 2.3 is my testing framework of choice.

It seems as though any stateless function component cannot be tested by TestUtils.renderIntoComponent or TestUtils.createRenderer().render(). Either returns null when rendering the function component.

Test with any stateless function component and it should yield the same result.

Component:

import React from 'react';

const User = ({name, age}) => ( return <div>{name}, {age}</div> );

module.exports = User;

Test:

expect(TestUtils.renderIntoDocument(<User name={"bob"} age={20} />)).toBeTruthy();

Error:

Expected null to be truthy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions