Monday, 24 April 2017

React assert css property on component

I have a react component like

const classNames = require('classNames/bind');
const someStyle = require('somestyle.scss');
const cx = classNames.bind(this);
const style = cx('someClass');
class Something extends React.Componenet {
   render() {
     return(<div className={style} />);
     }
}

My scss file is like

.someClass {
   width: 10px
}

I am trying to write a spec for unit testing this component to see if the width of that div tag is 10px or not. I am using enzyme+karma to shallow render my component. I am not able to find a way to assert this. Any help is much appreciated



via Anil Pediredla

No comments:

Post a Comment