Closed gregziegan closed 6 years ago
For DOM related things in before/after slate, we have to prepare JSDOM and enzyme with slate-simulator...
At current stage, slate-simulator is very simple.
Should we update the examples
folder to show some working tests? Or list JSDOM and enzyme as requirements for running tests with slate-simulator
?
Hey @thebritican thanks for opening this. Unfortunately, since Slate's Before/After
plugins rely on the DOM, and on the more complex contenteditable
aspects of the DOM, they aren't easily tested in isolation. I'm not even sure if JSDOM is complete enough to be used in its place either.
Do you want to request a feature or report a bug?
Bug
What's the current behavior?
When trying to run the test documented in https://docs.slatejs.org/other-packages/slate-simulator
Snippet:
I receive an invariant violation since ReactDOM tries to look for a DOM node via
findDOMNode
and has trouble finding the node insideSimulator
.Here's a JS fiddle showing this outside the context of a test (the test throws the same error). Check out the JS Console
https://jsfiddle.net/tk0jm1h8/
What's the expected behavior?
If this exception is not thrown, hopefully calls to a
Simulator
instance likesimulator.beforeInput({ data: 'h' })
will affect its state and we can then write expectations on the new state.Note: not passing
BeforePlugin()
into theSimulator
's plugins meansfocus()
does not throw an error... but any changes to thesimulator
instance do not reflect insimulator.value
.I'd love to help out, but I'd need some direction. Was this working before? Or am I missing an important setup? I also reproduced this with a vanilla
create-react-app
test suite.