You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get this error: "A component constructor could not be found for this class. Are you sure you passed in a the component definition for a React component? thrown"
and i use karma + babel
var React = require('react');
var TestUtils = require('react-addons-test-utils');
var ReactDOM = require('react-dom');
var rewire = require('rewire');
var jasmineReact = require('jasmine-react-helpers');
// var HelloRandom = require('../components/helloworld');
class HelloRandom extends React.Component {
getRandomAuthor() {
let names = [
'aliceyang',
'wangzhe',
'bill',
'cook'
];
return names[Math.floor(Math.random() * names.length)];
}
render() {
let name = this.getRandomAuthor();
return (
{ name }
);
}
};
describe("Hello Random", function () {
it("should spy on a function of react class", function () {
jasmineReact.spyOnClass(HelloRandom, 'getRandomAuthor').andReturn('wangzhe');
let HelloRandomComponent = TestUtils.renderIntoDocument(<HelloRandom/>);
expect(ReactDOM.findDOMNode(HelloRandomComponent).innerHTML).toEqual('wangzhe');
});
});
The text was updated successfully, but these errors were encountered:
I get this error: "A component constructor could not be found for this class. Are you sure you passed in a the component definition for a React component? thrown"
and i use karma + babel
var React = require('react');
var TestUtils = require('react-addons-test-utils');
var ReactDOM = require('react-dom');
var rewire = require('rewire');
var jasmineReact = require('jasmine-react-helpers');
// var HelloRandom = require('../components/helloworld');
class HelloRandom extends React.Component {
getRandomAuthor() {
let names = [
'aliceyang',
'wangzhe',
'bill',
'cook'
];
return names[Math.floor(Math.random() * names.length)];
}
render() {
let name = this.getRandomAuthor();
return (
);
}
};
describe("Hello Random", function () {
it("should spy on a function of react class", function () {
jasmineReact.spyOnClass(HelloRandom, 'getRandomAuthor').andReturn('wangzhe');
});
});
The text was updated successfully, but these errors were encountered: