I'm trying out the testUtils and some things are breaking. On node 0.11.12:
STDOUT:
~/Code/tests
❯ mocha test
․․
1 passing (125ms)
1 failing
1) test our tests should render a label:
Error: Invariant Violation: setEnabled(...): Cannot toggle event listening in a Worker thread. This is likely a bug in the framework. Please report immediately.
at invariant (/home/yoshua/Code/tests/node_modules/react/lib/invariant.js:52:19)
at Object.merge.setEnabled (/home/yoshua/Code/tests/node_modules/react/lib/ReactEventEmitter.js:206:46)
at ReactReconcileTransaction.EVENT_SUPPRESSION.initialize (/home/yoshua/Code/tests/node_modules/react/lib/ReactReconcileTransaction.js:58:23)
at ReactReconcileTransaction.Mixin.initializeAll (/home/yoshua/Code/tests/node_modules/react/lib/Transaction.js:197:30)
at ReactReconcileTransaction.Mixin.perform (/home/yoshua/Code/tests/node_modules/react/lib/Transaction.js:158:12)
at ReactComponent.Mixin.mountComponentIntoNode (/home/yoshua/Code/tests/node_modules/react/lib/ReactComponent.js:537:19)
at Object.<anonymous> (/home/yoshua/Code/tests/node_modules/react/lib/ReactMount.js:309:25)
at Object._renderNewRootComponent (/home/yoshua/Code/tests/node_modules/react/lib/ReactPerf.js:57:21)
at Object.ReactMount.renderComponent (/home/yoshua/Code/tests/node_modules/react/lib/ReactMount.js:359:32)
at Object.renderComponent (/home/yoshua/Code/tests/node_modules/react/lib/ReactPerf.js:57:21)
at Object.ReactTestUtils.renderIntoDocument (/home/yoshua/Code/tests/node_modules/react/lib/ReactTestUtils.js:57:18)
at Context.<anonymous> (/home/yoshua/Code/tests/test.js:38:23)
at callFn (/home/yoshua/.nvm/v0.11.12/lib/node_modules/mocha/lib/runnable.js:223:21)
at Test.Runnable.run (/home/yoshua/.nvm/v0.11.12/lib/node_modules/mocha/lib/runnable.js:216:7)
at Runner.runTest (/home/yoshua/.nvm/v0.11.12/lib/node_modules/mocha/lib/runner.js:374:10)
at /home/yoshua/.nvm/v0.11.12/lib/node_modules/mocha/lib/runner.js:452:12
at next (/home/yoshua/.nvm/v0.11.12/lib/node_modules/mocha/lib/runner.js:299:14)
at /home/yoshua/.nvm/v0.11.12/lib/node_modules/mocha/lib/runner.js:309:7
at next (/home/yoshua/.nvm/v0.11.12/lib/node_modules/mocha/lib/runner.js:247:23)
at Immediate._onImmediate (/home/yoshua/.nvm/v0.11.12/lib/node_modules/mocha/lib/runner.js:276:5)
at processImmediate [as _immediateCallback] (timers.js:374:17)
test.js:
/**
* Module dependencies
*/
var React = require('react/addons');
var should = require('should');
var mocha = require('mocha');
var jsdom = require('jsdom');
var utils = React.addons.TestUtils;
/**
* Initialize variables
*/
var document;
var window;
/**
* Initialize jsdom
*/
beforeEach(function() {
global.window = jsdom.jsdom().createWindow('<html><body></body></html>');
global.document = global.window.document;
});
/**
* Tests
*/
describe('test our tests', function() {
it('should display the window objects', function () {
global.window.should.exist;
global.document.should.exist;
});
it('should render a label', function () {
var label = utils.renderIntoDocument(React.DOM.label(null, 'hi'));
})
})
package.json:
{
"name": "tests",
"version": "0.0.0",
"description": "",
"main": "test.js",
"dependencies": {
"react": "^0.10.0"
},
"devDependencies": {
"mocha": "^1.18.2",
"jsdom": "^0.10.3",
"should": "^3.2.0-beta1"
},
"scripts": {
"test": "mocha"
},
"author": "Yoshua Wuyts",
"license": "MIT"
}
I'm trying out the testUtils and some things are breaking. On node
0.11.12:STDOUT:
test.js:
package.json: