0

I'm getting an issue with this code:

Import styles from '.treeView.css'

React.createClass({
   render(
     <div styleName={styles.treeNode>some text </div>
   );
});
})

My css is :

.treeNode { color:red }

This runs fine when running webpack with the css-loader. However I can no longer run my tests that import the above component as it complains about "unexpected token" starting on line 1 of the css file.

My npm test line in package.json is

mocha './src/**/*.tests.js' --compilers js:babel-core/register

I'm not certain whether this is an issue with my babel setup not being able to parse the css file.

Any help is appreciated.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
codeAline
  • 427
  • 1
  • 5
  • 9
  • You're missing a closing bracket on your `styleName` prop. – lux Jan 10 '17 at 18:10
  • Possible duplicate of [Mocha testing failed due to css in webpack](http://stackoverflow.com/questions/32236443/mocha-testing-failed-due-to-css-in-webpack) – Freez Jan 10 '17 at 19:29

1 Answers1

0

it should be

<div styleName={styles.treeNode}>some text </div>but not

<div styleName={styles.treeNode>some text </div>

shixukai
  • 1,805
  • 1
  • 9
  • 8