tntim96 / jscover Goto Github PK
View Code? Open in Web Editor NEWJSCover is a JavaScript Code Coverage Tool that measures line, branch and function coverage
License: GNU General Public License v2.0
JSCover is a JavaScript Code Coverage Tool that measures line, branch and function coverage
License: GNU General Public License v2.0
I cloned the repo, ran ant
, and got the following:
$ ant
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Buildfile: /Users/dalvarez/Code/JSCover/build.xml
clean:
dirsetup:
[mkdir] Created dir: /Users/dalvarez/Code/JSCover/target
[mkdir] Created dir: /Users/dalvarez/Code/JSCover/target/reports
[mkdir] Created dir: /Users/dalvarez/Code/JSCover/target/dist
[mkdir] Created dir: /Users/dalvarez/Code/JSCover/target/reports/test
[mkdir] Created dir: /Users/dalvarez/Code/JSCover/target/reports/spec
[mkdir] Created dir: /Users/dalvarez/Code/JSCover/target/reports/checkstyle
[mkdir] Created dir: /Users/dalvarez/Code/JSCover/target/reports/coverage/int
[mkdir] Created dir: /Users/dalvarez/Code/JSCover/target/reports/coverage/all
[mkdir] Created dir: /Users/dalvarez/Code/JSCover/target/classes/main
[mkdir] Created dir: /Users/dalvarez/Code/JSCover/target/classes/instrumented
[mkdir] Created dir: /Users/dalvarez/Code/JSCover/target/classes/test-unit
[mkdir] Created dir: /Users/dalvarez/Code/JSCover/target/classes/test-integration
[mkdir] Created dir: /Users/dalvarez/Code/JSCover/target/classes/test-acceptance
compile:
[javac] Compiling 27 source files to /Users/dalvarez/Code/JSCover/target/classes/main
[javac] Note: /Users/dalvarez/Code/JSCover/src/main/java/jscover/server/NanoHTTPD.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: /Users/dalvarez/Code/JSCover/src/main/java/jscover/server/NanoHTTPD.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[copy] Copying 13 files to /Users/dalvarez/Code/JSCover/target/classes/main
compile-tests:
[javac] Compiling 25 source files to /Users/dalvarez/Code/JSCover/target/classes/test-unit
[copy] Copying 6 files to /Users/dalvarez/Code/JSCover/target/classes/test-unit
compile-integration-tests:
[javac] Compiling 4 source files to /Users/dalvarez/Code/JSCover/target/classes/test-integration
[copy] Copying 136 files to /Users/dalvarez/Code/JSCover/target/classes/test-integration
cobertura-setup:
[cobertura-instrument] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
[cobertura-instrument] Cobertura 1.9.4.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[cobertura-instrument] Instrumenting 25 files to /Users/dalvarez/Code/JSCover/target/classes/instrumented
[cobertura-instrument] Cobertura: Saved information on 25 classes.
[cobertura-instrument] Instrument time: 225ms
[copy] Copying 149 files to /Users/dalvarez/Code/JSCover/target/classes/instrumented
run-tests:
[delete] Deleting directory /Users/dalvarez/Code/JSCover/target/reports/test
[mkdir] Created dir: /Users/dalvarez/Code/JSCover/target/reports/test
[junit] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
[junit] Testsuite: jscover.ConfigurationTest
[junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.058 sec
[junit]
[junit] Testsuite: jscover.MainInstanceTest
[junit] Tests run: 5, Failures: 0, Errors: 0, Time elapsed: 0.274 sec
[junit]
[junit] ------------- Standard Output ---------------
[junit] Usage: java -jar jscover.jar -ws [OPTION]...
[junit] Run a server for instrumenting JavaScript with code coverage information.
[junit]
[junit] Options:
[junit] --document-root=DIR serve content from DIR (default: current directory)
[junit] --no-instrument=URL do not instrument URL
[junit] --report-dir=DIR store report to DIR (default: current directory)
[junit] --port=PORT use PORT for TCP port (default: 8080)
[junit] --proxy run as a proxy
[junit] --js-version=VERSION JavaScript version 1.0, 1.2, ..., 1.8 (default: 1.3)
[junit] -h, --help display this help and exit
[junit]
[junit] Usage: java -jar jscover.jar -ws [OPTION]...
[junit] Run a server for instrumenting JavaScript with code coverage information.
[junit]
[junit] Options:
[junit] --document-root=DIR serve content from DIR (default: current directory)
[junit] --no-instrument=URL do not instrument URL
[junit] --report-dir=DIR store report to DIR (default: current directory)
[junit] --port=PORT use PORT for TCP port (default: 8080)
[junit] --proxy run as a proxy
[junit] --js-version=VERSION JavaScript version 1.0, 1.2, ..., 1.8 (default: 1.3)
[junit] -h, --help display this help and exit
[junit]
[junit] ------------- ---------------- ---------------
[junit] Testsuite: jscover.MainParsingTest
[junit] Tests run: 10, Failures: 0, Errors: 0, Time elapsed: 0.019 sec
[junit]
[junit] Testsuite: jscover.filesystem.ConfigurationForFSTest
[junit] Tests run: 10, Failures: 0, Errors: 0, Time elapsed: 0.011 sec
[junit]
[junit] ------------- Standard Error -----------------
[junit] Source directory 'unknown' is invalid
[junit] Source directory 'build.xml' is invalid
[junit] ------------- ---------------- ---------------
[junit] Testsuite: jscover.format.PlainFormatterTest
[junit] Tests run: 7, Failures: 0, Errors: 0, Time elapsed: 0.009 sec
[junit]
[junit] Testsuite: jscover.instrument.InstrumenterServiceTest
[junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.04 sec
[junit]
[junit] Testsuite: jscover.instrument.InstrumenterTest
[junit] Tests run: 9, Failures: 0, Errors: 0, Time elapsed: 0.016 sec
[junit]
[junit] Testsuite: jscover.instrument.LineCountNodeVisitorTest
[junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0.008 sec
[junit]
[junit] Testsuite: jscover.instrument.StatementBuilderTest
[junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.005 sec
[junit]
[junit] Testsuite: jscover.json.JSONDataMergerTest
[junit] Tests run: 5, Failures: 0, Errors: 0, Time elapsed: 0.015 sec
[junit]
[junit] Testsuite: jscover.json.JSONDataSaverTest
[junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.015 sec
[junit]
[junit] Testsuite: jscover.server.ConfigurationForServerTest
[junit] Tests run: 11, Failures: 0, Errors: 0, Time elapsed: 0.012 sec
[junit]
[junit] Testsuite: jscover.server.HttpRequestTest
[junit] Tests run: 5, Failures: 0, Errors: 0, Time elapsed: 0.009 sec
[junit]
[junit] Testsuite: jscover.server.InstrumentingRequestHandlerTest
[junit] Tests run: 7, Failures: 0, Errors: 0, Time elapsed: 0.047 sec
[junit]
[junit] Testsuite: jscover.server.WebServerTest
[junit] Tests run: 7, Failures: 0, Errors: 0, Time elapsed: 0.022 sec
[junit]
[junit] Testsuite: jscover.util.FileScannerTest
[junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.006 sec
[junit]
[junit] Testsuite: jscover.util.IoServiceTest
[junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0.013 sec
[junit]
[junit] Testsuite: jscover.util.IoUtilsTest
[junit] Tests run: 24, Failures: 0, Errors: 0, Time elapsed: 0.106 sec
[junit]
[junit] ------------- Standard Error -----------------
[junit] java.io.IOException: Ouch!
[junit] at jscover.util.IoUtils.closeQuietly(IoUtils.java:354)
[junit] at jscover.util.IoUtilsTest.shouldCloseStreamQuietly(IoUtilsTest.java:370)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] at java.lang.reflect.Method.invoke(Method.java:597)
[junit] at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
[junit] at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
[junit] at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
[junit] at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
[junit] at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
[junit] at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
[junit] at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
[junit] at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
[junit] at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
[junit] at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
[junit] at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
[junit] at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
[junit] at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
[junit] at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
[junit] at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
[junit] at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:518)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1052)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:879)
[junit] ------------- ---------------- ---------------
[junit] Testsuite: jscover.instrument.InMemoryCoverageTest
[junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.047 sec
[junit]
[junit] Testsuite: jscover.instrument.InstrumentAndHighlightRegressionTest
[junit] Tests run: 45, Failures: 0, Errors: 0, Time elapsed: 0.125 sec
[junit]
[junit] ------------- Standard Output ---------------
[junit] Test javascript-function-chain.js failed
[junit] Test javascript-getter-setter.js errored
[junit] Test javascript-iso-8859-1.js failed
[junit] ------------- ---------------- ---------------
[junit] Testsuite: jscover.instrument.InstrumenterIntegrationTest
[junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.005 sec
[junit]
[junit] Testsuite: jscover.instrument.ParseTreeInstrumenterIntegrationTest
[junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0.028 sec
[junit]
[junit] Flushing results...
[junit] Flushing results done
[junit] Cobertura: Loaded information on 25 classes.
[junit] Cobertura: Saved information on 25 classes.
Trying to override old definition of task cobertura-instrument
Trying to override old definition of task cobertura-merge
Trying to override old definition of task cobertura-check
Trying to override old definition of task cobertura-report
report-if-failed:
coverage-report:
[cobertura-report] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
[cobertura-report] Cobertura 1.9.4.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[cobertura-report] Cobertura: Loaded information on 25 classes.
[cobertura-report] Report time: 465ms
coverage-check:
[cobertura-check] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
[cobertura-check] Cobertura 1.9.4.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[cobertura-check] Cobertura: Loaded information on 25 classes.
[cobertura-check] All checks passed.
junit:
compile-acceptance-tests:
[javac] Compiling 3 source files to /Users/dalvarez/Code/JSCover/target/classes/test-acceptance
BUILD FAILED
/Users/dalvarez/Code/JSCover/build.xml:167: /Users/dalvarez/Code/htmlunit-2.10/lib does not exist.
Total time: 6 seconds
I found out JSCover will transfer wrong with no-ascii char.
My file charset is utf8
. And it contains some Chinese word.
Example:
// lib/regexp.js
var foo = /,|๏ผไฝ ๅฅฝ/ig;
After JSCover, it will come out:
// lib-cov/regexp.js
// ... ignore ....
_$jscoverage['regexp.js'].source = ["var foo = /,|,你好/ig;"];
_$jscoverage['regexp.js'][1]++;
var foo = /,|???/ig;
Is there any way to set java -jar JSCover-all.jar --encoding=utf8
params just like jscoverage --encoding=utf8
?
Hi,
I am trying to include the JAR in my java plugin for maven. I want to be able to launch / shutdown server from my plugin.
So far its working ok for launching using:
Main main = new Main();
main.runMain(args);
But I am wondering if there is a way to shutdown the server using the main class?
Thanks,
Josh
Clicking the "InstrumentAndHighlightRegressionTest" link gives a 404 error.
Can JsCover/JsCoverage be used to get stats of a complete Web application without any manual actions. The objective is to see the coverage in even in the presence of tag and without any manual feed.
I need to get coverage of all the web-pages of a web-site/Web-Application just via single command and without browsing to every single page manually.
When JSCover does filesystem instrumentation, the exit code is always zero, regardless of whether the instrumentation was successful or not. It should be non-zero in case of error.
When trying to merge multiple reports with --merge, the code seems to merge the json files properly, but then promptly copies cover the merged json report with one of the originals.
This create infinite loop -> java -jar C:\JSCover-0.0.11\target\dist\JSCover-all.jar -fs . webapp-instrumented
Hi I am getting below exception while using latest vesion with proxy server
java.lang.NullPointerException
at org.mozilla.javascript.Node.getChildBefore(Node.java:222)
at org.mozilla.javascript.Node.addChildBefore(Node.java:287)
at jscover.instrument.NodeProcessor.processNode(NodeProcessor.java:480)
at jscover.instrument.ParseTreeInstrumenter.visit(ParseTreeInstrumenter.java:367)
at org.mozilla.javascript.ast.IfStatement.visit(IfStatement.java:178)
at org.mozilla.javascript.ast.SwitchCase.visit(SwitchCase.java:149)
at org.mozilla.javascript.ast.SwitchStatement.visit(SwitchStatement.java:175)
at org.mozilla.javascript.ast.Block.visit(Block.java:61)
at org.mozilla.javascript.ast.FunctionNode.visit(FunctionNode.java:423)
at org.mozilla.javascript.ast.InfixExpression.visit(InfixExpression.java:182)
at org.mozilla.javascript.ast.ObjectLiteral.visit(ObjectLiteral.java:132)
at org.mozilla.javascript.ast.InfixExpression.visit(InfixExpression.java:182)
at org.mozilla.javascript.ast.ObjectLiteral.visit(ObjectLiteral.java:132)
at org.mozilla.javascript.ast.InfixExpression.visit(InfixExpression.java:182)
at org.mozilla.javascript.ast.VariableInitializer.visit(VariableInitializer.java:122)
at org.mozilla.javascript.ast.VariableDeclaration.visit(VariableDeclaration.java:151)
at org.mozilla.javascript.ast.Block.visit(Block.java:61)
at org.mozilla.javascript.ast.FunctionNode.visit(FunctionNode.java:423)
at org.mozilla.javascript.ast.FunctionCall.visit(FunctionCall.java:158)
at org.mozilla.javascript.ast.InfixExpression.visit(InfixExpression.java:182)
at org.mozilla.javascript.ast.ExpressionStatement.visit(ExpressionStatement.java:120)
at org.mozilla.javascript.ast.Block.visit(Block.java:61)
at org.mozilla.javascript.ast.FunctionNode.visit(FunctionNode.java:423)
at org.mozilla.javascript.ast.ParenthesizedExpression.visit(ParenthesizedExpression.java:75)
at org.mozilla.javascript.ast.FunctionCall.visit(FunctionCall.java:158)
at org.mozilla.javascript.ast.ExpressionStatement.visit(ExpressionStatement.java:120)
at org.mozilla.javascript.ast.ScriptNode.visit(ScriptNode.java:312)
at org.mozilla.javascript.ast.AstRoot.visitAll(AstRoot.java:110)
at jscover.instrument.SourceProcessor.instrumentSource(SourceProcessor.java:409)
at jscover.instrument.SourceProcessor.processSourceWithoutHeader(SourceProcessor.java:394)
at jscover.instrument.SourceProcessor.processSource(SourceProcessor.java:386)
at jscover.instrument.SourceProcessor.processSourceForServer(SourceProcessor.java:375)
at jscover.instrument.InstrumenterService.instrumentJSForWebServer(InstrumenterService.java:368)
at jscover.server.InstrumentingRequestHandler.handleGet(InstrumentingRequestHandler.java:434)
at jscover.server.HttpServer.run(HttpServer.java:403)
I instrumented by project using File Mode. Opened jscoverage.html and specified the path to the html page that runs qunit tests.
Tests ran and in the Summary tab I am also seeing the coverage information. Looking into the folder where jscoverage.html exists I don't see the jscoverage.json file. I don't see the store button on jscoverage.html. I was wondering where can I find the code coverage data that I can use for merging and so on.
I have couple of other questions, I will have them separate so it's easier to search for other people.
Thanks,
Rahul
For about 2/3 of my js files I am seeing this error when running
java -jar target/dist/JSCover-all.jar -fs --branch scripts/app jscover
this is a file that causes the issue
Exception in thread "main" org.mozilla.javascript.EvaluatorException: illegal character (ogs.checkout.Factory.js#1)
(function() {
function CheckoutFactory(api) {
var self = this;
self.createCheckout = function(model) {
var checkout = new window.checkout.CheckoutViewModel(model, api);
return checkout;
};
}
window.checkout.Factory = CheckoutFactory;
}());
but some larger more complex files seem to run ok. I'm not sure what's going on. Should I avoid using the -fs option?
The closer API found is:
public SortedMap<String, FileData> mergeJSONCoverageData(String data1, String data2)
But that handle just 2 JSONs, and the output is not a JSON so I cannot call it back in a loop passing the aggregate + new one.
At https://github.com/tntim96/JSCover/wiki
we should find a link to http://tntim96.github.com/JSCover/manual/manual.xml
Hi,
Today I find the new software and have a try, met some issue.
I implement the js code with JSCover, but run the html file failed. Check the implemented JS file, I found there has some Hexadecimal numeral error, like this:
" String.fromCharCode((c1 << 2) | ((c2 & 30) >> 4) & ff)",
while it should be :
"String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4) & 0xff)".
Could anyone give me a hand?
Thanks in advance!
Is it possible to make JSCover run PHP files?
Maybe you could add a CGI handler to pass off php files?
Code like below gives NPE on line defining "function(record)"
,onViewReady: function(view) {
var store = view.getStore(),
tree = this.getTree(),
treeStore = tree.getStore(),
checkNode = function(record) { // NPE HERE
this.checkNode(record, tree, treeStore);
};
store.each(checkNode, this);
},
Error on line 23 of app/controller/common/ContactPanel.js
java.lang.NullPointerException
at org.mozilla.javascript.Node.getChildBefore(Node.java:222)
at org.mozilla.javascript.Node.addChildBefore(Node.java:287)
at jscover.instrument.NodeProcessor.processNode(NodeProcessor.java:435)
at jscover.instrument.ParseTreeInstrumenter.visit(ParseTreeInstrumenter.java:371)
at org.mozilla.javascript.ast.FunctionNode.visit(FunctionNode.java:414)
at org.mozilla.javascript.ast.VariableInitializer.visit(VariableInitializer.java:122)
at org.mozilla.javascript.ast.VariableDeclaration.visit(VariableDeclaration.java:151)
at org.mozilla.javascript.ast.Block.visit(Block.java:61)
at org.mozilla.javascript.ast.FunctionNode.visit(FunctionNode.java:421)
at org.mozilla.javascript.ast.InfixExpression.visit(InfixExpression.java:182)
at org.mozilla.javascript.ast.ObjectLiteral.visit(ObjectLiteral.java:132)
at org.mozilla.javascript.ast.FunctionCall.visit(FunctionCall.java:160)
at org.mozilla.javascript.ast.ExpressionStatement.visit(ExpressionStatement.java:120)
at org.mozilla.javascript.ast.ScriptNode.visit(ScriptNode.java:312)
at org.mozilla.javascript.ast.AstRoot.visitAll(AstRoot.java:110)
at jscover.instrument.SourceProcessor.instrumentSource(SourceProcessor.java:410)
at jscover.instrument.SourceProcessor.processSourceWithoutHeader(SourceProcessor.java:394)
at jscover.instrument.SourceProcessor.processSource(SourceProcessor.java:386)
at jscover.instrument.SourceProcessor.processSourceForFileSystem(SourceProcessor.java:381)
at jscover.instrument.InstrumenterService.instrumentJSForFileSystem(InstrumenterService.java:375)
at jscover.filesystem.FileSystemInstrumenter.copyFolder(FileSystemInstrumenter.java:386)
at jscover.filesystem.FileSystemInstrumenter.copyFolder(FileSystemInstrumenter.java:382)
at jscover.filesystem.FileSystemInstrumenter.copyFolder(FileSystemInstrumenter.java:382)
at jscover.filesystem.FileSystemInstrumenter.copyFolder(FileSystemInstrumenter.java:382)
at jscover.filesystem.FileSystemInstrumenter.copyFolder(FileSystemInstrumenter.java:382)
at jscover.filesystem.FileSystemInstrumenter.run(FileSystemInstrumenter.java:367)
at jscover.Main.runFileSystem(Main.java:444)
at jscover.Main.runMain(Main.java:417)
at jscover.Main.main(Main.java:406)
In my project there are a few localization files which simply contain JS objects of key-value pairs for translation strings, they have a form like this :
({ string1: "some string", string2: "some other string" })
This is a rather strange (but valid) use of parentheses in JavaScript, making the file valid JSON and executable javascript, however JSCover is adding things after the first parenthesis, like this :
(if (! window.jscoverage_report) {
Which is sadly not valid JavaScript. I haven't had time to look any deeper into this but I think since immediately invoked functions (pattern like (function(){/*stuff here */})()
) are handled correctly, there should be a reasonably simple way to do the right thing in this case as well.
I have a JavaScript file encoded in UTF-8 with a BOM. Less from a Mingw console shows:
<U+FEFF>function ...
JSCover chokes on this:
Exception in thread "main" org.mozilla.javascript.EvaluatorException: illegal ch
aracter
at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultError
Reporter.java:77)
at org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporte
r.java:64)
at org.mozilla.javascript.Parser.addError(Parser.java:188)
at org.mozilla.javascript.Parser.addError(Parser.java:166)
at org.mozilla.javascript.Parser.addError(Parser.java:162)
at org.mozilla.javascript.TokenStream.getToken(TokenStream.java:832)
at org.mozilla.javascript.Parser.peekToken(Parser.java:296)
at org.mozilla.javascript.Parser.name(Parser.java:2880)
at org.mozilla.javascript.Parser.primaryExpr(Parser.java:2792)
at org.mozilla.javascript.Parser.memberExpr(Parser.java:2418)
at org.mozilla.javascript.Parser.unaryExpr(Parser.java:2316)
at org.mozilla.javascript.Parser.mulExpr(Parser.java:2241)
at org.mozilla.javascript.Parser.addExpr(Parser.java:2225)
at org.mozilla.javascript.Parser.shiftExpr(Parser.java:2206)
at org.mozilla.javascript.Parser.relExpr(Parser.java:2181)
at org.mozilla.javascript.Parser.eqExpr(Parser.java:2153)
at org.mozilla.javascript.Parser.bitAndExpr(Parser.java:2142)
at org.mozilla.javascript.Parser.bitXorExpr(Parser.java:2131)
at org.mozilla.javascript.Parser.bitOrExpr(Parser.java:2120)
at org.mozilla.javascript.Parser.andExpr(Parser.java:2109)
at org.mozilla.javascript.Parser.orExpr(Parser.java:2098)
at org.mozilla.javascript.Parser.condExpr(Parser.java:2062)
at org.mozilla.javascript.Parser.assignExpr(Parser.java:2033)
at org.mozilla.javascript.Parser.expr(Parser.java:2012)
at org.mozilla.javascript.Parser.nameOrLabel(Parser.java:1765)
at org.mozilla.javascript.Parser.statementHelper(Parser.java:1032)
at org.mozilla.javascript.Parser.statement(Parser.java:901)
at org.mozilla.javascript.Parser.parse(Parser.java:540)
at org.mozilla.javascript.Parser.parse(Parser.java:478)
at jscover.instrument.SourceProcessor.instrumentSource(SourceProcessor.j
ava:413)
at jscover.instrument.SourceProcessor.processSourceWithoutHeader(SourceP
rocessor.java:399)
at jscover.instrument.SourceProcessor.processSource(SourceProcessor.java
:391)
at jscover.instrument.SourceProcessor.processSourceForFileSystem(SourceP
rocessor.java:385)
at jscover.instrument.InstrumenterService.instrumentJSForFileSystem(Inst
rumenterService.java:376)
at jscover.filesystem.FileSystemInstrumenter.copyFolder(FileSystemInstru
menter.java:387)
at jscover.filesystem.FileSystemInstrumenter.copyFolder(FileSystemInstru
menter.java:383)
at jscover.filesystem.FileSystemInstrumenter.run(FileSystemInstrumenter.
java:368)
at jscover.Main.runFileSystem(Main.java:445)
at jscover.Main.runMain(Main.java:418)
at jscover.Main.main(Main.java:407)
I really appreciate the work done on this project.
The code is harder to read that what I'm used to see, it's very compact, uses a lot of output parameters instead of return, use structure instead of class, and have no JavaDoc.
I could make use of JavaDoc, and the JavaDoc could be available online.
When I use jscover as a web server, some js file load failed, while us jscoverage-server with parameter --encoding=utf-8 it can be loaded successfully, I thought this maybe caused by encoding issue. Does the jscover can support the parameter --encoding or is there some way can resolve the issue?
Can anyone give some suggestion on this?
Thanks for your support!
In my project, there has a jquery file "jquery-1.7.1.js", instrument the file there has many error in log, you can have a try first.
Thanks in advance!
It would be nice if JSCover could convert the jscoverage.json to a cobertura XML report for integration with Jenkins.
Running JSCover in webserver mode, while trying to access a picture containing a space character (ie. %20), the webserver returns a 404 error.
When running JSCover in proxy mode, and a .js file is requested, the ProxyService class does not send the original request headers to the actual server, causing behavior changes and some times complete failure, especially if the "Cookie" header is involved.
I've changed the ProxyService#getUrl method to send all of the original request headers, (except for the "Accept-Encoding" header) and everything worked perfectly after that.
here is the modified method:
public String getUrl(HttpRequest request) throws IOException {
URL url = request.getUrl();
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
Map<String, List<String>> clientHeaders = request.getHeaders();
if (clientHeaders != null) {
for (String header : clientHeaders.keySet()) {
if (header.equalsIgnoreCase("accept-encoding")) {
continue;
}
List<String> values = clientHeaders.get(header);
for (String value : values) {
conn.addRequestProperty(header, value);
}
}
}
return ioUtils.toString(conn.getInputStream());
}
I'm experimenting with using JSCover for coverage data generation in the Chutzpah test runner for .NET. As soon as the test run is over, I serialize the _$jscoverage
object using JSON.stringify
to eventually dump it to a file.
The problem is that the source
array is a property of the line count array, and JSON.stringify
simply ignores it. Currently, I have to preprocess _$jscoverage
before serializing it as a workaround.
It would be nice to get rid of the preprocessing, although I realize that this is a breaking change in that respect.
Hi, i'm not able to get the summary and source in the js coverage tool, even though the tests are running fine (i'm using qunit) . Is jscover dependent on the structure of the folder?
I'm currently coding using JSCover with UI automated test. I can retrieve for each test a JSON report, then merge all of them to one, then use the report tool usingjscoverage.html or Sonar (LCOV).
I do have the information to provide to JSCover which test is running. If somehow we can attach which test is touching a class/method, then we could know which tests to run to test a specific class and method.
I know this is advanced stuff, but I want to put it out there so someone may improve the idea or handle it.
I guess it's about being able to do report mining, and when you can do that you want more "properties" attached to "touch" points.
If I have webapp and webapp-instrumented as sibling folder, JSCover complains. I don't see any justification for this. Even more, if webapp-instrumented is a child of webapp, then JSCover recursives for ever.
C:\JSCover-0.0.11>java -jar C:\JSCover-0.0.11\target\dist\JSCover-all.jar -fs webapp webapp-instrumented
Destination directory 'webapp-instrumented' must be in the source directory
Usage: java -jar jscover.jar -fs [OPTION]... SOURCE-DIRECTORY DESTINATION-DIRECTORY
Instrument JavaScript with code coverage information.
Options:
--js-version=VERSION use the specified JavaScript version
--no-instrument=PATH copy but do not instrument PATH
--exclude=PATH don't copy from source/PATH
-h, --help display this help and exit
When I jscover my project, it throw this error, my js file code including Chinese charset.
Exception in thread "main" org.mozilla.javascript.EvaluatorException: illegal character
at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:77)
at org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:64)
at org.mozilla.javascript.Parser.addError(Parser.java:188)
at org.mozilla.javascript.Parser.addError(Parser.java:166)
at org.mozilla.javascript.Parser.addError(Parser.java:162)
at org.mozilla.javascript.TokenStream.getToken(TokenStream.java:831)
at org.mozilla.javascript.Parser.peekToken(Parser.java:296)
at org.mozilla.javascript.Parser.parse(Parser.java:524)
at org.mozilla.javascript.Parser.parse(Parser.java:502)
at jscover.instrument.SourceProcessor.instrumentSource(SourceProcessor.java:409)
at jscover.instrument.SourceProcessor.processSourceWithoutHeader(SourceProcessor.java:393)
at jscover.instrument.SourceProcessor.processSource(SourceProcessor.java:385)
at jscover.instrument.SourceProcessor.processSourceForFileSystem(SourceProcessor.java:380)
at jscover.instrument.InstrumenterService.instrumentJSForFileSystem(InstrumenterService.java:376)
at jscover.filesystem.FileSystemInstrumenter.copyFolder(FileSystemInstrumenter.java:386)
at jscover.filesystem.FileSystemInstrumenter.copyFolder(FileSystemInstrumenter.java:382)
at jscover.filesystem.FileSystemInstrumenter.copyFolder(FileSystemInstrumenter.java:382)
at jscover.filesystem.FileSystemInstrumenter.copyFolder(FileSystemInstrumenter.java:382)
at jscover.filesystem.FileSystemInstrumenter.copyFolder(FileSystemInstrumenter.java:382)
at jscover.filesystem.FileSystemInstrumenter.copyFolder(FileSystemInstrumenter.java:382)
at jscover.filesystem.FileSystemInstrumenter.run(FileSystemInstrumenter.java:367)
at jscover.Main.runFileSystem(Main.java:445)
at jscover.Main.runMain(Main.java:417)
at jscover.Main.main(Main.java:406)
Hi there,
I am using a command line script to start JSCover headless in Server Mode, and then, via CasperJs run my tests.
Currently I am stopping the server by pointing my headless browser to 0.0.0.0:8080/stop
But how do I write out the report before I stop the server? I missing something.
In the example below it's expected that "webapp-instrumented" folder will be created on the fly in the current folder, which is a sibling of "webapp"
c:\JSCover-0.0.12>dir /w
Volume in drive C is Windows7_OS
Volume Serial Number is B84D-1359
Directory of c:\JSCover-0.0.12
[.] [..] bookmarks.html build.properties build.xml
cobertura.ser [doc] example-filesystem.bat example-filesystem.sh example-server.bat
example-server.sh History.md JSCover.iml JSCover.ipr JSCover.iws
[lib] README.md [src] [target] Todo.md
[webapp]
14 File(s) 185,643 bytes
7 Dir(s) 55,451,303,936 bytes free
c:\JSCover-0.0.12>java -jar C:\JSCover-0.0.12\target\dist\JSCover-all.jar -fs webapp webapp-instrumented
Destination directory 'webapp-instrumented' must not be in the source directory
Usage: java -jar jscover.jar -fs [OPTION]... SOURCE-DIRECTORY DESTINATION-DIRECTORY
Instrument JavaScript with code coverage information.
Options:
--js-version=VERSION use the specified JavaScript version
--no-instrument=PATH copy but do not instrument PATH
--exclude=PATH don't copy from source/PATH
-h, --help display this help and exit
Hi, I encountered a piece of code that broke when annotated by JSCover, it goes like this:
if(true, false) {
// should never reach here
}
This makes use of the Javascript comma operator (https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Comma_Operator) that isn't used very often, but is used by the CoffeeScript compilers 'in' keyword.
JSCover generates the following code:
if(visit0_0_0(true, visit0_0_1(false)) {
_$jscoverage['myfile.js'][1]++;
// should never reach here
}
The visit0_0_0 call returns true, its first argument, instead of false, its last argument.
I bet there's an easy fix for this, but I'm working for a deadline at the moment so I didn't have time to make a pull request yet.
Kind regards,
Tinco
Should it be using this much CPU when idling?
Hi,
I seem to be getting malformed JSON in jscoverage.json sometimes. My guess on why this could be happening is we're running our tests in a parallel fashion and there needs to be some locking when reading / writing from jscoverage.json. I haven't invested if this critical section of code is actually threaded, so I might be talking nonsense.
I'll attach an example of malformed JSON that is being produced shortly.
Have any ideas why this could happen yourself?
Running in webserver mode.
Would a single JS method that return HTML or save HTML report without having to deal with frame/window when using inversed mode.
So ideally, if I include the jscover javascript library in my app (no point of having an html file), I would like to be able to call from anywhere, like Selenium something like "var myHTMLReport = jscoverage.getHTMLReport()" or "jscoverage.saveHTMLReport("myReport.html")
The button game or iframe mechanism is more work.
I just care about automated build.
I am trying to code coverage with JSCover on a set of unittests (written in Jasmine) executed with PhantomJS.
I have first instrumented the unittest files in the file system mode (with --fs option).
Then I run an ant target with PhantomJS executing run-jasmine on the instrumented files.
I get the error jscoverage_report variable is undefined. I don't see the variable defined in any of the instrumented files.
I think the documentation could be better for the PhantomJS use case.
Sonar is THE dashboard about project quality.
Sonar example: http://nemo.sonarsource.org/dashboard/index/420506?did=1
We need to be able to digest JSCover coverage data, see http://sonar.15.n6.nabble.com/JavaScript-plugin-analyzing-Mocha-JsCoverage-projects-td5000501.html
the coverage report has only the file name, it doesn't have the file path, this is an issue when I instrument files in different folder,I can't group them to the same root! so can't generate the reports!
Sorry, this'll be my last issue I swear...
I've searched through the manual for this but couldn't find anything for this particular scenario. I'm running in proxy mode, and the coverage report is working beautifully, but when I hit store and try to access the report using a simple web server, I can only view the summary, because there's no JS in the original-src dir of the report. Is there a way to have the proxy server save the JS files it proxied when storing the report?
Javascript in :
looking:
for(var nm in o){
JSCover out :
looking:
{
_$jscoverage['/web/dojo/_firebug/firebug.js'].lineData[1099]++;
_$jscoverage['/web/dojo/_firebug/firebug.js'].lineData[1100]++;
for (var nm in o) {
In JS you aren't allowed have statements between a label and its loop. I understand that the simplest fix would be to just move the label on to the loop line but it's a legacy project and I don't have the luxury of editing this particular dependency. JSCover looks great so far, I'm just inches away from getting it fully functional...
In the code coverage report, I am seeing code used to calculate code coverage as part of the source file and it's impacting real code coverage.
Below are the steps I performed:
Please advise.
Tried JSCover and must say it's so easy and nice to use, but I stumpled upon an error with the jQuery functions jQuery.map()
and jQuery.each
. It will show how often the these functions are called but will completely ignore the callback part, which is set to 0.
But the callback part is executed multiple times not the .map
/.each
.
E.g.:
$.map( [0,1,2], function(n){
return n + 4;
});
JSCover will show that line 1 is called 3 times and line 2 is never called.
Please provide ready build jars for download.
It's probably trivial for you to create the jars.
But I have to install Ant (which I don't know so well), which smells like trouble to me...
It'd be nice to have a ready made maven version for easy inclusion into another maven project.
As an extension, it would be nice to have a maven plugin for launching the server and killing it after the integration phase.
I can try and create a maven pom.xml for you in the next few days if you aren't familiar.
I'm running JSCover 0.1.1 in server mode. When I try to save the report JSON, I get this error in the server's log:
org.mozilla.javascript.EvaluatorException: missing ; before statement
at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:77)
at org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:64)
at org.mozilla.javascript.Parser.addError(Parser.java:188)
at org.mozilla.javascript.Parser.addError(Parser.java:166)
at org.mozilla.javascript.Parser.reportError(Parser.java:223)
at org.mozilla.javascript.Parser.reportError(Parser.java:210)
at org.mozilla.javascript.Parser.reportError(Parser.java:203)
at org.mozilla.javascript.Parser.autoInsertSemicolon(Parser.java:1067)
at org.mozilla.javascript.Parser.statementHelper(Parser.java:1044)
at org.mozilla.javascript.Parser.statement(Parser.java:901)
at org.mozilla.javascript.Parser.parse(Parser.java:540)
at org.mozilla.javascript.Parser.parse(Parser.java:478)
at jscover.instrument.LineCountNodeVisitor.getCodeLines(LineCountNodeVisitor.java:363)
at jscover.instrument.UnloadedSourceProcessor.getEmptyCoverageData(UnloadedSourceProcessor.java:376)
at jscover.server.InstrumentingRequestHandler.handlePost(InstrumentingRequestHandler.java:389)
at jscover.server.HttpServer.run(HttpServer.java:408)
This is true when running the report from either Chrome or Firefox, with the server on OS X 10.7.4, java v1.6.0_37.
I have a Windows Store app developed in JS. I was wondering how I could instrument the app to collect code coverage data.
Below is what I have done so far:
I was wondering how I could see the coverage data for this app?
Thanks,
Rahul
perhaps I'm missing something but example-server.sh looks for a file
target/dist/JSCover-all.jar
but it doesn't exist. I get the following error:
Unable to access jarfile target/dist/JSCover-all.jar
what am I missing? or is this a bug?
Hi,
Use the new build to instrument code, find some issue after instrumented code:
before :
var Count = base + Math.round( (Math.random() - 0.5) * base / 5);
after:
var Count = base + Math.round((Math.random() - 0x0.5) * base / 0x5);
also:
supported = {'a':3.0,'b:7,'c':4,'d':2};
supported= {'a': 0x3.0, 'b': 0x7, 'c': 0x4, 'd': 0x2};
There has some error with instrument decimals, please help check on it.
Thanks in advance!
When use JSCover with -ws mode and parameter --report-dir=/JsCover/report , add button to trigger the event, but can't save the report successful in my side, can anyone give me some support on this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.