HarryChen0506 / react-markdown-editor-lite

a light-weight Markdown editor based on React. 一款轻量的基于React的markdown编辑器
https://harrychen0506.github.io/react-markdown-editor-lite/
MIT License
1.04k stars 160 forks source link

[BUG] jest 测试环境中,上传图片异常 uuid is not a function #231

Closed zjhou closed 3 years ago

zjhou commented 3 years ago

OS and browser

Windows 10 & jsdom

Description

jest 的测试用例中模拟图片上传,运行用例时报错。(cjs 目录下的工具函数 getUploadPlaceholder,uuid is not a function)

用例

  it('should throw error after upload file if upload props is missing', () => {
    expect(() => {
      const onChange = jest.fn();
      const wrapper = mount(<MarkdownEditor onChange={onChange} />);
      const file = new File([fileContents], 'test.png', { type: 'image/png'})
      wrapper
        .find('.button-type-image > input')
        .simulate('change', { target: { files: [file] } });
    }).toThrowError('uploadProps is not found');
  });

报错信息

image

zjhou commented 3 years ago

相关 bug:https://github.com/HarryChen0506/react-markdown-editor-lite/issues/230

sylingd commented 3 years ago

fixed