Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6 style import results in test errors #113

Open
rufman opened this issue Sep 29, 2016 · 0 comments
Open

ES6 style import results in test errors #113

rufman opened this issue Sep 29, 2016 · 0 comments

Comments

@rufman
Copy link

rufman commented Sep 29, 2016

Local chai-enzyme config

When configuring chai-enzyme globally I have failing tests, but if I add the following to the file with the failing tests it works:

import chai from 'chai'
import chaiEnzyme from 'chai-enzyme'
chai.use(chaiEnzyme())

Global chai-enzyme config

Importing chai-enzyme as a CommonJs module and configuring it globally works fine, but the ES6 style import causes tests to fail.

import chaiEnzymeEs6 from 'chai-enzyme' // Doesn't work
const chaiEnzyme = require('chai-enzyme') // Works fine

logging the export of each of these shows that chaiEnzymeEs6 === chaiEnzyme

Also, test fails in the same way when chai-enzyme is imported before stubbing the global window and document using js-dom.

Errors on failing tests

The errors I get in tests that are submitting a reduxForm, each failing due to some (related?) issue:

Invariant Violation: findComponentRoot(..., .10vfrs14k8w.1.1.1.0.1): Unable to find element. This probably means the DOM was unexpectedly mutated (e.g., by the browser), usually due to forgetting a <tbody> when using tables, nesting tags like <form>, <p>, or <a>, or using non-SVG elements in an <svg> parent. Try inspecting the child nodes of the element with React ID ``.

Invariant Violation: processUpdates(): Unable to find child 1 of element. This probably means the DOM was unexpectedly mutated (e.g., by the browser), usually due to forgetting a <tbody> when using tables, nesting tags like <form>, <p>, or <a>, or using non-SVG elements in an <svg> parent. Try inspecting the child nodes of the element with React ID `.10vfrs14k8w.1.1.0.0`.

Invariant Violation: dangerouslyRenderMarkup(...): Cannot render markup in a worker thread. Make sure `window` and `document` are available globally before requiring React when unit testing or use ReactDOMServer.renderToString for server rendering.

I have little knowledge about the internals of require vs ES6 imports, but something weird is going on there. Maybe someone else has some more insight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant