Javascript testing

I am currently working on my first Javascript project, which is generally a bit of a script that manages the Thunderbird extension. Since I'm a Java programmer, I like to test my code to keep it working and to check if it works as expected.

The thing I want to test is a simple script that basically retrieves the URI, connects to the server, downloads the zip file, and finally extracts it to the file system. I do not use Javascript - "classes", I have only these 2-3 functions collected in the main function.

I would like to combine the server to test the behavior of the script with various server responses, corrupted files, etc.

Now my problem is that I really don't know how to test in javascript. I tried to get an overview of the available test systems and finally decided that Jasmine is the one I want to use because it seems to be the most mature of them.

I am well versed in unit tests in Java and consider myself an average testing engineer, but it is difficult for me to access all the testing script.

Does anyone have any good advice on how to do this? Maybe a useful tutorial or a good example?

+5
source share
1 answer

The approach is probably the same one you would use in Java: Highlight a class / function that retrieves data.

, XMLHttpRequest, :

  • ,
  • mock
  • , .

"Test Driven JavaScript Development"

+1

All Articles