Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define Best Practices for Unit Tests #3

Open
tobiasschweizer opened this issue Feb 13, 2020 · 2 comments
Open

Define Best Practices for Unit Tests #3

tobiasschweizer opened this issue Feb 13, 2020 · 2 comments
Assignees
Labels

Comments

@tobiasschweizer
Copy link
Contributor

tobiasschweizer commented Feb 13, 2020

AngularNYC - Angular Unit Testing Best Practices - Joe Eames (@josepheames) gives a good introduction to what can be considered best practices for unit testing. Note that in the video unit tests are referred to as tests of a component's class only whereas integration tests also include a component's template (DOM).

The Angular testing guide recommends to "test DOM interaction with unit testing techniques" (https://angular.io/guide/testing#why-not-defer-dom-integration-tests-to-end-to-end-e2e-testing). I think it is crucial to include the DOM in the tests because much of our components' complexity comes from interaction with user input and reacting to it. The Angular testing guide also states that "a component is more than just its class. A component interacts with the DOM and with other components. The class-only tests can tell you about class behavior. They cannot tell you if the component is going to render properly, respond to user input and gestures, or integrate with its parent and child components." (https://angular.io/guide/testing#component-dom-testing).

So I think it all comes to the question what is considered to be unit. I think the DOM should be part of a unit test (also referred to as a DOM integration test).

@tobiasschweizer
Copy link
Contributor Author

tobiasschweizer commented Feb 13, 2020

@tobiasschweizer
Copy link
Contributor Author

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

No branches or pull requests

1 participant