jeudi 25 février 2016

JavaScript UnitTest or End to End Test

At the moment I try to work with my dev-teammates on some modular system for our javascript solutions. Because we're able to start on a "green plane" we'd like to do it right this time - with tests!

We found Jasmine and Karma for our Unit Tests and Selenium/Nightwatch for our End-to-End tests.

While I was writing unit tests for those components of the system which never touched any DOM through JQuery I was good to go. But one day I came along some components which manipulates the DOM. So far so good. I managed to test them as well thanks to Jasmine-JQuery. Until this point I was sure to still be within the boundaries of Unit-Testing.

Yesterday tho, I was sitting in front of a component which will make a navigation bar sticky (or fixed) as soon as the user is about to scroll the webpage down.

I wanted to test this functionality with Jasmine-JQuery again. What I did was - I mocked the users scrolling with "window.scrollTo(0, 2000)" and then checked if the attributes of those navigation bar have been changed.

The Issue:

My teamleader put me on hold because I have stepped over to the domain for End-To-End tests because I needed to mock browser functionality.

My Questions: Is this really the case? In my optinion an End-To-End test should test the orchestration of several functionalities of a system (like ours) within a productive environment. Therefore User-Stories would be the layer I would test with End-To-End tests. Check if the path a user has to go to login and write an article (for example) works the way as intended. But checking if a javascript component will successfully add/remove attributes to the DOM after some event (like the scroll event) happened - should be a unit test still.

I'm an apprentice developer - I respect the experience of my teamleader - but I still want to make completely sure that things will be done the right way.

So I ask you guys/girls if you might tell me when Unit-Testing ends and when End-To-End tests begin when writing JavaScript and manipulating the DOM

I'm looking forward to read a lot of good arguments!

greets Charlie

Aucun commentaire:

Enregistrer un commentaire