Trying to perform a first test in a new component... However in the code below the renderIntoDocument method returns a empty object. It is good to point out that the component works fine in the main app, rendered using webpack. No other error is throw! Thanks in advance
import React from 'react';
import TestUtils from 'react-dom/test-utils';
import TwistCardComponent from '../lib/twist-card-component';
describe('Render TwistCardComponent into document', function() {
let component;
beforeEach(function() {
component = TestUtils.renderIntoDocument(<TwistCardComponent />);
});
it('should render', function() {
console.log(component);
expect(component.getDOMNode().className).toEqual(
'twist-card-component');
});
});
component
import React from 'react';
import createReactClass from 'create-react-class';
const TwistCardComponent = createReactClass({
render() {
return (
<div className='twist-card-component'>Hello World!</div>
);
}
});
export default TwistCardComponent;
** package.json **
{
"name": "twist-card-component",
"version": "1.0.0",
"description": "twist card component",
"scripts": {
"test": "eslint lib/ spec/ && ./node_modules/karma/bin/karma start karma.conf.js",
"watch-test": "./node_modules/karma/bin/karma start karma.conf.js --auto-watch --no-single-run",
"build": "webpack -p --display-error-details --colors",
"start": "webpack-dev-server --inline --hot"
},
"author": "",
"license": "BSD",
"keywords": [
"react",
"reactjs",
"react-component"
],
"main": "dist/index.js",
"files": [
"dist"
],
"devDependencies": {
"babel-core": "~5.8.22",
"babel-eslint": "^4.1.8",
"babel-loader": "~5.3.2",
"css-loader": "~0.16.0",
"es5-shim": "~4.1.10",
"eslint": "^0.21.1",
"eslint-plugin-react": "^2.3.0",
"jasmine": "~2.3.2",
"jasmine-core": "~2.3.4",
"karma": "^1.7.1",
"karma-jasmine": "^0.3.8",
"karma-phantomjs-launcher": "^0.2.3",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.4",
"node-sass": "^3.13.1",
"phantomjs": "^2.1.7",
"phantomjs-prebuilt": "^2.1.15",
"react": "^15.6.1",
"react-addons-test-utils": "^15.6.0",
"react-dom": "^15.6.1",
"sass-loader": "~2.0.1",
"sourcemap": "^0.1.0",
"style-loader": "~0.12.3",
"webpack": "^1.15.0",
"webpack-dev-server": "~1.10.1"
},
"dependencies": {
"babel-runtime": "~5.8.20"
}
}
Aucun commentaire:
Enregistrer un commentaire