lathonez / clicker

Ionic 2 + @angular/cli Seed Project : Angular2 + Typescript + Karma + Protractor + Travis
http://lathonez.com/2018/ionic-2-unit-testing/
MIT License
430 stars 137 forks source link

Styles in Karma Tests #231

Closed jb-int closed 7 years ago

jb-int commented 7 years ago

Is there a way to get styles in Karma tests, so I can run a unit test to show the screen at a particular state and tweak the design that way?

I'm aware Protractor could work, but as far as I know protractor doesn't allow for mocking up services that I need to get to a particular state. That part is much easier using Karma.

lathonez commented 7 years ago

Hey,

This is something I've wondered about - but no I don't think it's possible. This answer on SO sums it up nicely: http://stackoverflow.com/questions/25965884/should-we-use-css-in-karma-unit-level-tests-in-angularjs-projects

Basically, the most you should be doing in unit testing is checking that elements have expected classes applied to them.

Happy to be corrected.

Stephen