Closed marr closed 7 years ago
Current status: mocha doesn't like window when I use mocha
and karma doesn't like webpack[Jsonp] if I karma start
. Errors:
!!
karma start
INFO [karma]: Karma v0.12.35 server started at http://localhost:9876/
INFO [launcher]: Starting browser ChromeCanary
WARN [web-server]: 404: /favicon.ico
INFO [Chrome 45.0.2420 (Mac OS X 10.10.3)]: Connected on socket Aym65ehI_O6-lTHphf-K with id 21556998
Chrome 45.0.2420 (Mac OS X 10.10.3) ERROR
Uncaught ReferenceError: webpackJsonp is not defined
at /Users/dmarr/src/status/test/index.js:1
Chrome 45.0.2420 (Mac OS X 10.10.3): Executed 0 of 0 ERROR (0.138 secs / 0 secs)
dmarr@dmarr ~/src/status (master) $ mocha
/Users/dmarr/src/status/test/common.js:3
window.React = require('react');
^
ReferenceError: window is not defined
at Object.<anonymous> (/Users/dmarr/src/status/test/common.js:3:1)
at Module._compile (module.js:456:26)
at normalLoader (/Users/dmarr/src/status/node_modules/babel/node_modules/babel-core/lib/babel/api/register/node.js:150:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/dmarr/src/status/node_modules/babel/node_modules/babel-core/lib/babel/api/register/node.js:163:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at args (/Users/dmarr/src/status/node_modules/mocha/bin/_mocha:308:3)
at Array.forEach (native)
at Object.<anonymous> (/Users/dmarr/src/status/node_modules/mocha/bin/_mocha:307:10)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:929:3
The configs I'm playing with are here: https://gist.github.com/bc03dcff4e5feef7a2a5
I'm struggling with webpack and karma, and an example of those w/mocha would be most appreciated. DOM and mocha aren't guaranteed, and thats why webpack helps us, build bundles from typically node code (require) etc, mocha uses (describe) and I had an epihany earlier today which I can't get working again: Hot reloading with the mocha-loader. Will attempt to PR this likely through an npm
run-script
like:Note, just today I realized that with --output-file testBundle.js (for example) you would browse to http://localhost:8080/testBundle and see the mocha html runner spun up and updating in place. It was glorious -- link forthcoming if i can achieve that with karma start or something. I think maybe including the test suite in iframe mode would be helpful. I just want a way to get TestUtils.RenderIntoDocument working the simplest possible way in a test suite.