Inside my code I use babel-plugin-react-css-modules which is practically the same as react-css-modules
I have a code like this inside react component.
styleName
is for CSS Modules and I define styles for them inside countdownForm.local.scss
className
represent my Bootstrap classes
import './countdownForm.local.scss'
class CountdownForm extends Component {
...
render () {
return (
<div styleName="first" className="container">
...
</div>
)
}
}
To test this component inside my test I have to use ignore-styles
package because JavaScript can't handle CSS syntax and when we run unit tests, the test will try to import the CSS file without Webpack which will result error.
import register from 'ignore-styles'
import React from 'react'
import test from 'tape'
import CountdownForm from 'CountdownForm'
register(undefined, () => ({styleName: 'fake_class_name'}))
test('CountdownForm => should exist', (t) => {
t.ok(CountdownForm)
t.end()
})
By doing this everything passes great and test works without problem but I always get this warning in the console
Warning: Unknown prop
styleName
on tag. Remove this prop from the element.
It is not a problem of functionality because tests works but it is annoying to get this message every time I run tests. How to fix, get rid of it?