Say your Javascript performs some element/position calculations e.g. in angularjs directive.
In order to test this Javascript code is it appropriate to include CSS in karma.conf.js ?
I see that some popular projects did include css files.
e.g. ng-grid
project karma.conf.js
'dist/release/ui-grid.css',
The questions is more towards the boundary of e2e tests vs. unit tests.
As far as I understand your question, here's my take on this -
Unit test are to check functionality of particular source code.
There are following ways to do unit testing for a function
If a method in directive is manipulating css, then it should be adding and removing CSS class inside that method, isn't it? So in assertions it need to check only if particular class is present or not. (In most of the cases which I worked on)
CSS file is external file and its a dependancy for javascript source file & it should be treated as dependancies.
Where as e2e testing is the like integration testing, to make sure if all integration files work together perfectly. So if we need to test CSS changes, we should check with e2e.
Here is interesting talk on Unit Testing from Miško Hevery. It's not related to CSS, but in general Unit Testing & about handling dependancies(17:50)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With