Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: Can't find variable _$jscoverage #9

Closed
ghost opened this issue Oct 17, 2014 · 8 comments
Closed

ReferenceError: Can't find variable _$jscoverage #9

ghost opened this issue Oct 17, 2014 · 8 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Oct 17, 2014

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.

@tntim96
Copy link
Owner

tntim96 commented Oct 18, 2014

The plugin runs the tests one by one and saves the report on the last test. Can you ensure that the last test has instrumented code (which will have the _$jscoverage variable).

@tntim96 tntim96 self-assigned this Oct 18, 2014
@ghost
Copy link
Author

ghost commented Oct 20, 2014

It seems like the jscoverage.js page in my output directory folder was being included in the tests, and that's not being instrumented. So after i added the output directory folder for the JSCover results to the no-instrument arguments they tests are passing the build is succeeding. So everything seems to be fine now, thanks very much for investigating this.

One small additional thing, when loading the jscoverage.html page in my chrome browser there is a slight issue where I don't see all test coverage results, with a error on the page:
Error: TypeError: Cannot read property 'lineData' of undefined.

But after I refresh the page all the results show fine. I know this is unrelated to the original issue but thought I'd mention it.

@tntim96
Copy link
Owner

tntim96 commented Oct 20, 2014

Error: TypeError: Cannot read property 'lineData' of undefined

Thanks for noting that.

What version and OS?
Are you loading from the network or the filesystem?
Are you adding the start-up option --allow-file-access-from-files for Chrome?
Does it always happen, or only with a particular report? (If only with that report, could you upload it somewhere? No need to include the original-src folder)

@ghost
Copy link
Author

ghost commented Oct 28, 2014

Sorry for the late response. I'm running Chrome Version 38.0.2125.111 m, on Windows 7. Loading from the network, and I have tried with the --allow-file-access-from-files option. It is happening intermittently on any reports, not specific.

@tntim96
Copy link
Owner

tntim96 commented Oct 28, 2014

@ghost
Copy link
Author

ghost commented Nov 4, 2014

Sorry again for the late reply, I was away. It does not occur with the above page.

@tntim96
Copy link
Owner

tntim96 commented Nov 4, 2014

What version of JSCover is the report?

Also, could you upload a sample that has the issue? I haven't been able to reproduce it.

@ghost
Copy link
Author

ghost commented Nov 11, 2014

The version is 1.0.14. Unfortunately I can't upload any of the reports as I currently don't have access to the build being done before. When I'm able to test again, I will provide an update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant