Unexpect error occurrence? Houston, we have a problem… but only if the JavaScript you wrote is not easily testable.
We’ve all experienc it – a small
JavaScript function of a few lines grows, and suddenly we have a dozen lines, and the next, there are two dozen. Arguments are gradually pack on the function, conditional statements grow by a few more conditions, and one day an error message appears. Something has gone wrong and it’s up to us to deal with the mess.
The article was translat with the kind permission of . The original text of the article (EN) can be found here: .
Along with the ever-increasing shift of responsibility to the client side (after all, at the moment the entire application lives its own life mainly in browsers), two things are more obvious. First, we can’t just decide what to test to make sure everything works as it should – automat tests are a key helper to verify the correctness of the code. Second, if we want to include tests in the script, we will probably have to change the way we write the code.
Do we really ne to change the way we code? Yes, we must. Although we know that automat tests are a great tool, we italy phone number data probably only write integration tests at this point. These are important tests, they verify the functioning of all parts of the application as a whole, but we will no longer know whether the individual parts work as we expect.
This is the right time for unit tests. And until we start writing testable JavaScript, we will have trouble writing unit tests.
Unit tests versus integration tests – what’s the difference?
Writing integration tests is not complicat, we make sure that contact information simply write code that describes the interaction between the user and the application and what the user should expect to see during this interaction. A popular browse bz lists automation tool i and communication with it is facilitat by (for Ruby); we can find an abundance of tools for other programming languages as well.