quill-image-uploader
quill-image-uploader copied to clipboard
quill-image-uploader breaks Jest test.
Did anyone get to run jest test successfully in a component that imports quill-image-uploader
?
-
Test suite failed to run ({"Object.
":function(module,exports,require,__dirname,__filename,global,jest){import './blots/image'; ^^^^^^^^^^^^^^^
SyntaxError: Unexpected string
3 | import { connect } from 'react-redux' 4 | import ReactQuill, { Quill } from 'react-quill' 5 | import ImageUploader from 'quill-image-uploader'
I made a change to how the blots/image
was handled in the latest release.
Not sure if it will fix your issue or not.
If you could give the miminum reproducible example then I would be happy to take a closer look at it.
Hello, @NoelOConnell sorry for the late reply, i did try using the lib(with the last update) again but the same error occurred.
I'm on a private project so can't share here but, all i did is to test the render of a component, like this:
Component.jsx
import React, { Component } from "react"
import { bindActionCreators } from "redux"
import { connect } from 'react-redux'
import ReactQuill, { Quill } from 'react-quill'
import ImageUploader from 'quill-image-uploader'
Quill.register("modules/imageUploader", ImageUploader)
component.test.js
import React from 'react'
import { mount } from 'enzyme'
import Component from './Component'
describe('<Component />', () => {
it('should render correctly', () => {
const component = mount(
<Component />
)
expect(component).toMatchSnapshot()
component.unmount()
})
})
I'll try reproducing it on a simple app and then share the repo in here.
Thank you!
Having the same issue :(
I resolved this in my project by changing the jest config's transformIgnorePatterns
value.
'/node_modules'
-> '/node_modules/(?!quill-image-uploader).+\\.js$'
Are there any news on this?
I had the same issue here and I solved it by using the identity-obj-proxy
in my jest.config.js
moduleNameMapper: { ..., 'quill-image-uploader': 'identity-obj-proxy', }
Similar problem here, solved by mocking out the library everywhere where it was failing. Would be more ideal to get a proper fix in the library.
jest.mock('quill-image-uploader', () => ({}));