This is my script to rune2e with instrumenting: As you can see I create an instrumented copy of my js files. change index.html to reference the instrumented files (with sed) the script:
#!/bin/bash BASE_DIR=`dirname $0` echo "" echo "Istanbul instrumenting js files" echo "-------------------------------------------------------------------" istanbul instrument $BASE_DIR/../app/js -o $BASE_DIR/../app/instrumentjs echo "" echo "Building an instrumented index.html" echo "------------------------------------------------------------------" cat $BASE_DIR/../app/index.html | sed s/\"js/\"instrumentjs/ > app/index_e2etest.html echo "" echo "Starting node.js local webserver to run the tests" echo "-------------------------------------------------------------------" node $BASE_DIR/../scripts/web-server.js > /dev/null 2>&1 & echo "" echo "Starting Karma Server (http://karma-runner.github.io)" echo "-------------------------------------------------------------------" karma start $BASE_DIR/../config/karma-e2e.conf.js $* Also: in my karma-e2e.conf I added the following lines: preprocessors: { '../app/instrumentjs/**/*.js': 'coverage' }, Setting the coverage plugin to check the instrumented js files we created before Twitter:@alonisser <https://twitter.com/alonisser> LinkedIn Profile <http://www.linkedin.com/in/alonisser> Facebook <https://www.facebook.com/alonisser> *Tech blog:*4p-tech.co.il/blog *Personal Blog:*degeladom.wordpress.com Tel:972-54-6734469 On Tue, Aug 5, 2014 at 12:47 AM, Xiaohui Chen <[email protected]> wrote: > I think my problem is the way instrumented files were put on the server. > You mention you have a special index.html, so I'd like to see how you did > it. Please post it if not too much trouble. I appreciate your help. > > Tony > On Aug 4, 2014 2:09 PM, "alonn" <[email protected]> wrote: > >> Since Angular moved to Protractor I didn't post the working solution - >> If this is still relevant to you I can post it here >> >> >> >> Twitter:@alonisser <https://twitter.com/alonisser> >> LinkedIn Profile <http://www.linkedin.com/in/alonisser> >> Facebook <https://www.facebook.com/alonisser> >> *Tech blog:*4p-tech.co.il/blog >> *Personal Blog:*degeladom.wordpress.com >> Tel:972-54-6734469 >> >> >> On Mon, Aug 4, 2014 at 11:49 PM, Xiaohui Chen <[email protected]> >> wrote: >> >>> Have you got chance to post your solution yet? Cause I am working on a >>> similar project but put files instrumented by istanbul on server did not >>> work. >>> >>> >>> On Thursday, October 31, 2013 12:56:59 AM UTC-7, Alon Nisser wrote: >>>> >>>> It can be done (figured it a few days ago) - Also hacky (At least the >>>> js part, not the html) I'll be posting later the exact process I use, but >>>> mainly I use istanbul intrument to create an instrumented js folder for my >>>> app/js, I create (on the fly) an alternative index.html to load this js >>>> instead of the regular js and changed scenario.js files to use the changed >>>> index.html instead of the orginial one >>>> I automated everything in the e2e-tesh.sh. >>>> >>>> I hope later today (or tomorrow) I'll have to to post a full solution >>>> >>>> On Thursday, October 31, 2013 4:25:43 AM UTC+2, Jack Zhang wrote: >>>>> >>>>> Well, thank you for your replay. >>>>> >>>>> But we really need a way which can help us measure the coverage of our >>>>> e2e test in our project. We want a quantifiable report to guarantee the >>>>> quality of e2e test. If karma can not do this, do you have other >>>>> solutions ? >>>>> >>>>> Very appreciate for your response. >>>>> >>>>> On Thursday, October 31, 2013 2:19:07 AM UTC+8, Daniel Tabuenca wrote: >>>>>> >>>>>> I don't believe you can do this with karma for end to end tests. >>>>>> During normal unit testing the files are served by karma itself so it can >>>>>> instrument them and fully control things. During end-to-end testing, the >>>>>> files are being served by your web server. >>>>>> >>>>>> If you are looking for javascript coverage, you might want to look at >>>>>> using Istanbul (the library karma is using for coverage) directly. >>>>>> >>>>>> https://github.com/yahoo/istanbul >>>>>> >>>>>> >>>>>> On Wednesday, October 30, 2013 2:52:13 AM UTC-7, Jack Zhang wrote: >>>>>>> >>>>>>> >>>>>>> >>>>>>> I used angularjs e2e for my project's end2end test i can also run >>>>>>> that in karma. >>>>>>> >>>>>>> I know i can use 'karma-coverage' plugin to measure my code >>>>>>> coverage, but this is only for unit test. >>>>>>> >>>>>>> Now, i want to measure End2End Test coverage which help me know how >>>>>>> much my test cases have coverage scenario, Anyone can tell me how to >>>>>>> measure end2end test coverage automatically? >>>>>>> >>>>>>> -- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "AngularJS" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/angular/leh6qVceZ8s/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at http://groups.google.com/group/angular. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "AngularJS" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/angular/leh6qVceZ8s/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/angular. >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "AngularJS" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/angular/leh6qVceZ8s/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
