question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Full DOM rendering test fails at react-quill component.

See original GitHub issue

I’m using react-quill component in my app. Everything works fine except tests. I was writing some unit tests for my components. When I test my App component to simply render the app (using Enzyme’s mount method), it fails rendering Quill component. Here is output:

    Error: Uncaught [ReferenceError: MutationObserver is not defined]
console.error node_modules/react-dom/cjs/react-dom.development.js:15123
    The above error occurred in the <Quill> component:
        in Quill (at board.js:64)
        in div (at board.js:63)
        in div (at board.js:62)
        in div (at board.js:49)
        in Board (created by WrappedBoard)
        in span (created by WrappedBoard)
        in div (created by WrappedBoard)
        in WrappedBoard (at app.js:19)
        in div (at app.js:17)
        in div (at app.js:16)
        in div (at app.js:14)

React-Quill version

1.3.2

To reproduce:

  1. Set up React app using create-react-app
  2. Add react-quill component
  3. Use react-quill component somewhere in your app
  4. Add enzyme to your app
  5. Write a unit test like this one:
import React from 'react';
import { mount } from 'enzyme';
import App from '../App';
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

it('renders without crashing', () => {
  mount(<App />);
});

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:14

github_iconTop GitHub Comments

19reactions
adambaialievcommented, Dec 24, 2018

Hi! I am using Jest and I have setupTests.js file where I put global mocks. This code helped me with the same problem…

global.MutationObserver = class {
  constructor(callback) {}
  disconnect() {}
  observe(element, initObject) {}
  takeRecords() {return []}
};
global.document.getSelection = function() {}
1reaction
labkey-nickacommented, Sep 25, 2020

@lyctw I realize this was awhile ago but did you end up finding a solution for when you have a custom toolbar? I’m also receiving the error of the classList being null.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Full DOM rendering test fails at react-quill component.
I'm using react-quill component in my app. Everything works fine except tests. I was writing some unit tests for my components.
Read more >
reactjs - Jest tests not passing even though component seems ...
I am trying to understand why the tests are failing. Failing Tests. App.test.js import React from 'react'; import ...
Read more >
react-quill-fixed - npm
The Quill rich-text editor as a React component. ... Start using react-quill-fixed in your project by running `npm i react-quill-fixed`.
Read more >
Build a WYSIWYG text editor using Quill - LogRocket Blog
`npm i react-quill`. Once the installation is complete, open the App.js file, import the ReactQuill component, and include it into the App ...
Read more >
cannot read properties of null (reading 'usecontext') jest
Store isn't a React component so it can't use the useStore hook. ... I removed react-dom as one of my dependencies and it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found