tntim96 / JSCover

JSCover is a JavaScript Code Coverage Tool that measures line, branch and function coverage
GNU General Public License v2.0
399 stars 84 forks source link

On-fly test coverage stucked #312

Closed ipadkid-sketchy closed 2 years ago

ipadkid-sketchy commented 2 years ago

I'm new with JSCover.

I've read the manual and viewed the examples but I still can't apply it on our projects.

We have this site (http://xxxx.xx.com:20500/dir/dir) that is being run on https but based on the article I've read, there's no way to get the coverage of the HTTPS sites. So what we did was provided a http site of that site.

These are the steps I did.

Pre-requisites:

  1. Run the jscover-proxy.bat on a cmd. This is the content of the bat java -jar target\dist\JSCover-all.jar -ws --proxy --port=3128 --report-dir=target/jscover-proxy
  2. Opened the http://localhost:3128/jscoverage.html
  3. Supplied the (http://xxxx.xx.com:20500/dir/dir) in URL field
  4. The site then loads up but there was an error encountered which is described below Uncaught DOMException: Blocked a frame with origin "http://xxxx.xx.com:20500/dir/dir" from accessing a cross-origin frame.
  5. No reports was being created, no scripts generated, json file was empty now I'm stucked.

Basically, JSCover have 3 modes and we want to implement the on-fly coverage method which is the server mode.

If anyone can give insights on how we can proceed, that will be a great help. Thank you!

tntim96 commented 2 years ago

This example does what you want https://github.com/tntim96/JSCover/tree/master/examples/localStorage-file-system

Basically you have to file-instrument the code, and upload them to your server before running the tests.

ipadkid-sketchy commented 2 years ago

The thing is we don't have the source code to instrument the file or is it a pre-requisite?

tntim96 commented 2 years ago

It's a pre-requisite

ipadkid-sketchy commented 2 years ago

So to confirm we can't test the site on-fly? We have to have our own copy of the source code to instrument the files? What if we don't have the source code for example, we want to test coverage the google site?

tntim96 commented 2 years ago

That would be a problem because that code is minified, and JSCover works best by instrumenting the original source.

ipadkid-sketchy commented 2 years ago

image

Tried the samples on the link you've provided but got an error. Tried googling it and they said that storeEval is changed with execute-script. I tried changing it to execute-script but still same error

tntim96 commented 2 years ago

Good pickup. I replaced storeEval with execute script and it worked for me.