Open gilmillasseau opened 7 years ago
Hi @gilmillasseau ,
This test setup works for me: https://github.com/jpuri/react-draft-wysiwyg/blob/master/config/test-setup.js for JSDOM. Looks like tests and not getting dom elements.
I have anyways added some null checks to avoid this situation. Change will be released soon.
I'm getting the same issue, even with the added HTMLElement
and AnchorElement attributes added.
var jsdom = require('jsdom').jsdom
var LocalStorage = require('node-localstorage').LocalStorage
var exposedProperties = ['window', 'navigator', 'document', 'localStorage']
global.localStorage = new LocalStorage('../localStorageTemp')
global.window.localStorage = global.localStorage
global.document = jsdom('')
global.window = document.defaultView
global.window.confirm = s => s
global.HTMLElement = window.HTMLElement
global.HTMLAnchorElement = window.HTMLAnchorElement
Object.keys(document.defaultView).forEach((property) => {
if (typeof global[property] === 'undefined') {
exposedProperties.push(property)
global[property] = document.defaultView[property]
}
})
global.navigator = {
userAgent: 'node.js'
}
Test
// ava and enzyme
test('componentDidMount sets editor state', t => {
const Wrapper = mount(<NewCommentForm editorProps={{/* props for editor */}} />)
})
// where NewCommentForm is like
const NewCommentForm = ({editorProps}) => <div><Editor {...editorProps} /></div>
throws Cannot read proptery 'addEventListener' of null.
Thank you for already looking into this!
Test
Subject
mocha setup
I am having always the same output
TypeError: Cannot read property 'addEventListener' of null