Giter Club home page Giter Club logo

jscover-maven-plugin's People

Contributors

cezarytarnowski-tomtom avatar tntim96 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jscover-maven-plugin's Issues

Add tests

This project is easily tested against JSCover-samples, but needs internal tests to speed up development.

Running instrumentation over root directory did not work

The directory structure is like,

project

  • project-impl
  • project-components
  • project-util
  • project-tools
  • project-examples
  • project-integrations

<configuration>
<srcDir>${project.home}</srcDir>
<testDirectory>${project.home}/project-impl/src/test</testDirectory>
<branchCoverageMinimum>100</branchCoverageMinimum>
<functionCoverageMinimum>100</functionCoverageMinimum>
<lineCoverageMinimum>100</lineCoverageMinimum>
<excludeArgs>
<excludeArg>--exclude=project-util</excludeArg>
<excludeArg>--exclude=project-tools</excludeArg>
<excludeArg>--exclude=project-examples</excludeArg>
<excludeArg>--exclude=project-integrations</excludeArg>
</excludeArgs>
</configuration>

So that just didn't work, it recursively created target directories one inside the other and so on with no instrumented code in it and it almost got stuck, I stopped it. If I change the above configuration to, say a specific module, then it works, like srcDir=project-impl

So because of this, I guess I will have to instrument specific modules one by one, into separate directories (because target will get overwritten with next module) and then move those directories under one location.

ReferenceError: Can't find variable _$jscoverage

Dear Admin,

Thanks for providing the JSCover plugin for maven. It seems when building to run the tests fine, but after the tests passed there is a failure during the build process:

"Execution default of goal com.github.tntim96:jscover-server-maven-plugin:1.0.11:jscover failed: Timed out after 1 seconds waiting for text ('%') to be present in element found by By.id: summaryTotal"

Looking up at other messages, it seems to begin from an error saying:
"ReferenceError: Can't find variable _$jscoverage"

I'm not sure whether this is a bug, or a problem with my configuration, which I based off the sample page. Checking the jscoverage.html page that is generated, the code coverage seems to be working regardless. Currently I have it configured as follows:

    <plugin>
        <groupId>com.github.tntim96</groupId>
        <artifactId>jscover-server-maven-plugin</artifactId>
        <version>1.0.11</version>
        <executions>
            <execution>
                <phase>verify</phase>
                <goals>
                    <goal>jscover</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <testDirectory>myTestDirectory</testDirectory>
            <testIncludes>unitTests.html</testIncludes>
            <testType>QUnit</testType>
            <lineCoverageMinimum>0</lineCoverageMinimum>
            <branchCoverageMinimum>0</branchCoverageMinimum>
            <functionCoverageMinimum>0</functionCoverageMinimum>
            <timeOutSeconds>30</timeOutSeconds>
            <timeOutSecondsForSave>20</timeOutSecondsForSave>
            <instrumentPathArgs>
                <arg>--no-instrument=myTestFolder</arg>
                <arg>--no-instrument=myTargetFolder</arg>
            </instrumentPathArgs>
            <includeUnloadedJS>true</includeUnloadedJS>
            <reportCoberturaXML>true</reportCoberturaXML>
            <reportDir>target/reports</reportDir>
            <webDriverClassName>org.openqa.selenium.phantomjs.PhantomJSDriver</webDriverClassName>
        </configuration>
    </plugin>

And for dependencies:

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.43.1</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-api</artifactId>
        <version>2.43.1</version>
    </dependency>
    <dependency>
        <groupId>com.github.detro.ghostdriver</groupId>
        <artifactId>phantomjsdriver</artifactId>
        <version>1.1.0</version>
        <exclusions>
            <exclusion>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-remote-driver</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-server</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

I've searched online but I can't seem to find anything relating to this issue. Thanks very much for your response in advance.

Unable to get plugin to work - cannot download files

I have my pom file set up as such:

com.github.tntim96 jscover-file-maven-plugin 1.0.4-SNAPSHOT ./aura-impl/src/test
        <testType>QUnit</testType>

        <instrumentPathArgs>
            <arg>--no-instrument=target</arg>
        </instrumentPathArgs>
        <includeUnloadedJS>true</includeUnloadedJS>
        <reportCoberturaXML>true</reportCoberturaXML>
        <reportLCOV>true</reportLCOV>


    </configuration>
</plugin>

When I run my jenkins build, it says in the console:
[WARNING] The POM for com.github.tntim96:jscover-file-maven-plugin:jar:1.0.4-SNAPSHOT is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for com.github.tntim96:jscover-file-maven-plugin:1.0.4-SNAPSHOT: Plugin com.github.tntim96:jscover-file-maven-plugin:1.0.4-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.github.tntim96:jscover-file-maven-plugin:jar:1.0.4-SNAPSHOT

then fails because it doesn't know the maven command for the file plugin. What am I doing wrong?

Don't understand how to use jscover-server-maven-plugin with Jasmine

Hi! I'm trying to use jscover-server-maven-plugin with Jasmine specs but can't do it...
Here is my file structure:

pom.xml
-- src
-- -- main
-- -- -- webapp
-- -- -- -- javascript
-- -- -- -- -- store.js
-- -- -- -- -- utils.js
-- -- test
-- -- -- javascript
-- -- -- -- store-spec.js
-- -- -- -- utils-spec.js

I'm using jQuery and defined a Maven dependency with webjars:

    <dependency>
      <groupId>org.webjars</groupId>
      <artifactId>jquery</artifactId>
      <version>${jquery.version}</version>
      <scope>runtime</scope>
    </dependency>

I'm using jasmine-maven-plugin to execute my Jasmine unit test and I'd like to get code coverage in order to inject the LCOV report into my SonarQube server.

Here is my plugin configuration after many tries:

          <plugin>
            <groupId>com.github.tntim96</groupId>
            <artifactId>jscover-server-maven-plugin</artifactId>
            <version>1.0.20</version>
            <executions>
              <execution>
                <phase>verify</phase>
                <goals>
                  <goal>jscover</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <detail>true</detail>
              <documentRoot>target/jscover-temp</documentRoot>
              <testDirectory>target/jscover-temp</testDirectory>
              <testType>Jasmine</testType>
              <webDriverClassName>org.openqa.selenium.phantomjs.PhantomJSDriver</webDriverClassName>
              <reportLCOV>true</reportLCOV>
              <systemProperties>
                <property>
                  <name>phantomjs.binary.path</name>
                  <value>${phantomjs.binary}</value>
                </property>
              </systemProperties>
            </configuration>
          </plugin>

As you can see, I've tried to copy all resources into temp folder 'target/jscover-temp' with the SpecRunner.html generated by the jasmine-maven-plugin. With this configuration, I've the following error:

...
[INFO] 
[INFO] --- jscover-server-maven-plugin:1.0.20:jscover (default) @ test-js-with-jasmine ---
[INFO] Started JSCover server
[INFO  - 2017-07-20T18:36:06.720Z] GhostDriver - Main - running on port 12753
[INFO  - 2017-07-20T18:36:06.883Z] Session [4aefd9c0-6d7a-11e7-b26f-9d09483cb888] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1","webSecurityEnabled":true}
[INFO  - 2017-07-20T18:36:06.883Z] Session [4aefd9c0-6d7a-11e7-b26f-9d09483cb888] - page.customHeaders:  - {}
[INFO  - 2017-07-20T18:36:06.883Z] Session [4aefd9c0-6d7a-11e7-b26f-9d09483cb888] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"2.1.1","driverName":"ghostdriver","driverVersion":"1.2.0","platform":"windows-10-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO  - 2017-07-20T18:36:06.883Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 4aefd9c0-6d7a-11e7-b26f-9d09483cb888
[info] Clearing local storage: http://localhost:8080/jscoverage-clear-local-storage.html
[info] Testing SpecRunner.html
[ERROR - 2017-07-20T18:36:08.170Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1500575768163

  phantomjs://platform/console++.js:263 in error
[ERROR - 2017-07-20T18:36:08.981Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1500575768926

  phantomjs://platform/console++.js:263 in error
[ERROR - 2017-07-20T18:36:09.779Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1500575769722

  phantomjs://platform/console++.js:263 in error
[ERROR - 2017-07-20T18:36:10.575Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1500575770519

  phantomjs://platform/console++.js:263 in error
[ERROR - 2017-07-20T18:36:11.356Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1500575771313

  phantomjs://platform/console++.js:263 in error
[ERROR - 2017-07-20T18:36:12.137Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1500575772095

  phantomjs://platform/console++.js:263 in error
[ERROR - 2017-07-20T18:36:12.920Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1500575772876

  phantomjs://platform/console++.js:263 in error
[ERROR - 2017-07-20T18:36:13.717Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1500575773659

  phantomjs://platform/console++.js:263 in error
[ERROR - 2017-07-20T18:36:14.498Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1500575774454

  phantomjs://platform/console++.js:263 in error
[ERROR - 2017-07-20T18:36:15.295Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1500575775237

  phantomjs://platform/console++.js:263 in error
[ERROR - 2017-07-20T18:36:16.074Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1500575776034

  phantomjs://platform/console++.js:263 in error
[ERROR - 2017-07-20T18:36:16.855Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1500575776813

  phantomjs://platform/console++.js:263 in error
[ERROR - 2017-07-20T18:36:17.637Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1500575777595

  phantomjs://platform/console++.js:263 in error
[ERROR - 2017-07-20T18:36:18.419Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1500575778378

  phantomjs://platform/console++.js:263 in error
[INFO  - 2017-07-20T18:36:18.465Z] ShutdownReqHand - _handle - About to shutdown
[INFO] Stopped JSCover server
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 28.279 s
[INFO] Finished at: 2017-07-20T20:36:19+02:00
[INFO] Final Memory: 20M/277M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.tntim96:jscover-server-maven-plugin:1.0.20:jscover (default) on project test-js-with-jasmine: Execution default of goal com.github.tntim96:jscover-server-maven-plugin:1.0.20:jscover failed: Expected condition failed: waiting for presence of element located by: By.className: jasmine-duration (tried for 10 second(s) with 500 MILLISECONDS interval)
[ERROR] Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
[ERROR] System info: host: 'PC-Salon', ip: '192.168.1.100', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_77'
[ERROR] Driver info: org.openqa.selenium.phantomjs.PhantomJSDriver
[ERROR] Capabilities [{applicationCacheEnabled=false, rotatable=false, handlesAlerts=false, databaseEnabled=false, version=2.1.1, platform=XP, browserConnectionEnabled=false, proxy={proxyType=direct}, nativeEvents=true, acceptSslCerts=false, driverVersion=1.2.0, locationContextEnabled=false, webStorageEnabled=false, browserName=phantomjs, takesScreenshot=true, driverName=ghostdriver, javascriptEnabled=true, cssSelectorsEnabled=true}]
[ERROR] Session ID: 4aefd9c0-6d7a-11e7-b26f-9d09483cb888: {"errorMessage":"Unable to find element with class name 'jasmine-duration'","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"49","Content-Type":"application/json; charset=utf-8","Host":"localhost:12753","User-Agent":"Apache-HttpClient/4.5.2 (Java/1.8.0_77)"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"class name\",\"value\":\"jasmine-duration\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/4aefd9c0-6d7a-11e7-b26f-9d09483cb888/element"}}
[ERROR] Command duration or timeout: 280 milliseconds
[ERROR] For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
[ERROR] Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
[ERROR] System info: host: 'PC-Salon', ip: '192.168.1.100', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_77'
[ERROR] Driver info: org.openqa.selenium.phantomjs.PhantomJSDriver
[ERROR] Capabilities [{applicationCacheEnabled=false, rotatable=false, handlesAlerts=false, databaseEnabled=false, version=2.1.1, platform=XP, browserConnectionEnabled=false, proxy={proxyType=direct}, nativeEvents=true, acceptSslCerts=false, driverVersion=1.2.0, locationContextEnabled=false, webStorageEnabled=false, browserName=phantomjs, takesScreenshot=true, driverName=ghostdriver, javascriptEnabled=true, cssSelectorsEnabled=true}]
[ERROR] Session ID: 4aefd9c0-6d7a-11e7-b26f-9d09483cb888
[ERROR] *** Element info: {Using=class name, value=jasmine-duration}: Screen shot has been taken
[ERROR] Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
[ERROR] System info: host: 'PC-Salon', ip: '192.168.1.100', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_77'
[ERROR] Driver info: driver.version: RemoteWebDriver: {"errorMessage":"Unable to find element with class name 'jasmine-duration'","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"49","Content-Type":"application/json; charset=utf-8","Host":"localhost:12753","User-Agent":"Apache-HttpClient/4.5.2 (Java/1.8.0_77)"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"class name\",\"value\":\"jasmine-duration\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/4aefd9c0-6d7a-11e7-b26f-9d09483cb888/element"}}
[ERROR] For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
[ERROR] Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
[ERROR] System info: host: 'PC-Salon', ip: '192.168.1.100', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_77'
[ERROR] Driver info: driver.version: unknown
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

The problem is that:

  • I don't really understand how jscover-server-maven-plugin is designed and which file/web structure is needed.
  • the plugin documentation is a little bit poor
  • not sure that the problem is on the maven plugin configuration

Any help will be appreciated!

Question: JSCover with jasmine custom runner template

Hi,

I would like to use JSCover-maven-plugin to show coverage of jasmine tests. To run the jasmine tests, I use the jasmine-maven-plugin, using a custom runner template(http://searls.github.io/jasmine-maven-plugin/spec-runner-templates.html), which is defined using the "customRunnerTemplate" property of the configuration.

When using the jscover-server-maven-plugin, how do I define the custom runner to use like in the jasmine-maven-plugin? Without specifying this, I get an empty runner page when calling "mvn jscover-server:jscover" without the list of tests.

Thanks.

jscoverage_serializeCoverageToJSON is not defined

My jscover-maven build is failing with the following message:

jscoverage_serializeCoverageToJSON is not defined

I know that it is failing at the following line from FileTestRunner:

String json = (String)((JavascriptExecutor) webClient).executeScript("return jscoverage_serializeCoverageToJSON();");

What causes this message? it seems like it's not finding the javascript method. I'm using the selenium Chromedriver, downloaded straight from Google. Haven't made any additions to it.

I'm not sure what I need to do. When I run my integration tests, I have a java class that gathers the tests together and runs them. I'm not using a framework like unit.js or qunit. What do I need to do?

Report failed tests

Currently, when the Javascript tests fail (e.g. Jasmine or QUnit), it is not possible to determine which tests failed.

execution of "jscover-file" stops after configuration

hi,

when i run mvn jscover-file:jscover, the execution stops with the following output:

[INFO] --- jscover-file-maven-plugin:1.0.7:jscover (default-cli) @ <project_name> ---

executing it with -X, the execution lists the configuration and stops there.

I am trying to use jscover-file to show the coverage of jasmine tests.

What could be the issue here?

Thank you.

Question: how to stop JSCover from launching browser?

Hello,

Am trying to use JSCover with a different test runner, which is headless javascript tests (not phantom or jasmine). So I first instrument all the code and then run the tests as a different execution from pom.xml. But seems like JSCover automatically tries to run tests using whatever driver config etc..which then throws exception.

[ERROR] Failed to execute goal com.github.tntim96:jscover-file-maven-plugin:1.0.15:jscover (default) on project aura-framework: Execution default of goal com.github.tntim96:jscover-file-maven-plugin:1.0.15:jscover failed: java.lang.reflect.InvocationTargetException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

So all I want to know is to stop JSCover once it's done instrumenting.

It's possible to remove the IE driver?

Hi, I'm using linux, I want to use this with jenkins in a Linux environment, my application only need to use the PhantomJS driver, because is a chrome only application.

Is possible to remove all the anothers webdriver and use only the phantomjs driver?
How can I do that.

Thank you

testDirectory

Hi,

I'm using jscover-file-maven-plugin to instrument my JS files only.
Configuration tag "testDirectory" is required but I don't use it, I have to put a fake "srcDir" sub-directory.

Is it possible to make it optional?

Thank you

Timed out after 10 seconds for saving storage data

Dear admin,

We use this plugin to do regular jscover scan in our project. But it has a limitation with 10 seconds to save storage data. I found below code. We have a big project to scan, the result is big. May you give us a configuration or make 30 seconds around?
new WebDriverWait(webClient, 10).until(ExpectedConditions.textToBePresentInElementLocated(By.id("storeDiv"), "Coverage data stored at"));

Thanks,
Chuanyu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.