Skip to content

TypeError: Cannot read property 'play' of undefined #909

@Tokimon

Description

@Tokimon

Current Behavior

When you change the playing prop during test (using Jest), the following error is thrown.

TypeError: Cannot read property 'play' of undefined

Expected Behavior

No Error to be thrown

Steps to Reproduce

React component

import React from 'react';
import ReactPlayer from 'react-player';

const VideoTest = ({ play }) => {
  return (
    <ReactPlayer
      url='./test-video.mp4'
      playing={!!play}
      className='react-player'
      width='100%'
      height='100%'
      style={{ lineHeight: 0 }}
    />
  );
};

VideoTest.displayName = 'VideoTest';

export default VideoTest;

Test File

import React from 'react';
import { mount } from 'enzyme';

import VideoTest from './VideoTest';

describe('[molecule] VideoPlayerTest', () => {
  it('testing resetting play', () => {
    const wrapper = mount(<VideoTest file='http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4' />);

    wrapper.setProps({ play: true });
    wrapper.setProps({ play: false });
  });
});

Environment

  • Test runner: Jest
  • Browser: JsDom
  • Operating system: Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions