CodeCoverage for functional automation in NodeJS applications

I am looking for pointers to a tool that can help me determine the coverage of functional automation in nodeJs. (These are not single tests!).

I have a lot of selenium automation for my external application written in NodeJS. But I want to know the functional scope of this automation.

(I used jacoco for java based earlier)

+5
source share
2 answers

Answer to this question: istanbul-middleware https://github.com/gotwarlost/istanbul-middleware

istanbul and istanbul-middleware are different from each other and must be installed separately. I have successfully used the code using this. The steps are as follows

  • add istanbul-middleware to your nodejs application
  • add toolkit code during the launch of your application. An example is provided on github.
  • Then start the node server and run its selenium tests against it.
  • if you run in localhost, you can go to /coverage (or if you changed it from the github example, change it here) and get information about your coverage.

Read more in the github readme file.

+1
source

As mentioned in one of the comments, Istanbul is a really good, very general coverage tool. It acts like an average person between the node process and your scripts, so while you are doing something in the node runtime, it should do what you want. I'm not sure how you do selenium tests, but I go through mocha like this:

 node ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- test/*-test.js #or simply: ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- test/*-test.js 

Despite the fact that mocha usually starts as its own β€œteam”, it can be β€œfed” in istanbul, and the cover is printed in this way. Therefore, in your case, any command that you use to run interface tests in node / selenium can be run in istanbul. As I said, this is a very general process that can be applied to everything that works in node.js.

Now I have no experience with Selenium, but I know that this is a bit of a Rube Goldberg system with many interconnected processes (some potentially on different machines). If you are looking for something to capture both the first and the backends, as well as test code (or external code running in a browser, served from the internal code) in one line, I am not sure what exists ("an external application written in NodeJS ") is what put me in this).

+2
source

Source: https://habr.com/ru/post/1204665/


All Articles