Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Unit testing directives/services w/o a browser env #427

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

iphands
Copy link
Contributor

@iphands iphands commented Feb 12, 2018

Hey guys, I want to start breaking down directive code into more testable/composible pieces, then write small focused unit tests that can execute quickly and are not dependant on a browser environment.

Opening this MR up so we can start discussing what we do and don't like about this kind of approach.

I will write some more examples and squash before the actual merge

@iphands iphands requested review from jharting and Kinlaw February 12, 2018 15:21
@iphands iphands changed the title Unit testing directives w/o a browser env Unit testing directives/services w/o a browser env Feb 12, 2018
@jharting
Copy link
Member

@iphands IMHO this is a bit too complicated (functions to produce actual functions, passing $scope, ...). I think you can get the same outcome by using AngularJS' built-in tooling for mock injection and unit testing. See e.g. https://github.com/RedHatInsights/insights-frontend/blob/master/test/unit/components/maintenanceTable_spec.js#L78

We would likely still need to make changes to controllers to make them more easily testable however I expect these changes to be lighter.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants