react-draft-wysiwyg
react-draft-wysiwyg copied to clipboard
Use a function to generate an ID if you need to
I can't use react snapshots when testing my use of the WYSIWYG editor because of:
https://github.com/jpuri/react-draft-wysiwyg/blob/9be932d1a00f26468aa349b0118f310ba212f0b7/src/Editor/index.js#L103
If you use a function, then I could target it and mock it.
Right now I'm doing:
beforeEach(
() => {
StyleSheetTestUtils.suppressStyleInjection();
Math.random = jest.fn(() => 123);
}
);
which I don't like, because I do use Math.random in other places.
Hey @sontek , can you try to pass wrapperId and check, that should work.
Hey @sontek I know its been too late to comment here Just commenting for helping others
If snapshots are keep updating, as because of wrapper ID is keep updating.
So just provide wrapperID prop to the react-draft-WYSIWYG Editor as
<Editor wrapperID="some-id" in the main component of react-draft-WYSIWYG