douglasduteil / isparta

:skull: A code coverage tool for ES6 (babel/6to5)
Do What The F*ck You Want To Public License
642 stars 47 forks source link

Virtual DOM (jsdom) not available globally before requiring React #129

Open desytech opened 7 years ago

desytech commented 7 years ago

Setup

Using enyzme's full lifecycle rendering https://github.com/airbnb/enzyme/blob/master/docs/api/mount.md and it seem that jsdom have to be initialized globally before isparta includes all sources!

CLI call babel-node node_modules/isparta/bin/isparta cover --report html --include-all-sources --root 'src/js/' --include '**/*.js' _mocha -- --require ./test/setup.js --recursive ./test

Issue with --include-all-sources i get following error

Invariant Violation: dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a worker thread. Make surewindowanddocumentare available globally before requiring React when unit testing or use ReactDOMServer.renderToString() for server rendering.

without iam getting no error, but also an uncompleted coverage report

Q is there any way to initialize jsdom before isparta includes the sources?