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

mvn test - Htmlunit not finding files with requirejs integration #110

Closed
phtrivier opened this issue Oct 1, 2012 · 0 comments
Closed

mvn test - Htmlunit not finding files with requirejs integration #110

phtrivier opened this issue Oct 1, 2012 · 0 comments

Comments

@phtrivier
Copy link

Hi

I'm using the requirejs integration with the following in my pom.xml :

           <plugin>
            <groupId>com.github.searls</groupId>
            <artifactId>jasmine-maven-plugin</artifactId>
            <version>1.2.0.0</version>
            <extensions>true</extensions>
            <executions>
              <execution>
                <goals>
                  <goal>test</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
                <specRunnerTemplate>REQUIRE_JS</specRunnerTemplate>
                <jsSrcDir>${project.basedir}/src/main/resources/web/resources</jsSrcDir>
                <scriptLoaderPath>vendor/requirejs/require.js</scriptLoaderPath>
                <sourceIncludes>
                  <include>vendor/EventEmitter/EventEmitter.js</include>
                </sourceIncludes>
                <jsTestSrcDir>${project.basedir}/src/test/spec</jsTestSrcDir>
            </configuration>
          </plugin>

My spec uses require js to fetch its dependencies this way :

function requireDependencies(deps, cb) {
    deps = Array.isArray(deps) ? deps : [ deps ];

    beforeEach(function() {
        var done = false;
        runs(function() {
            require(deps, function() {
                cb && cb.apply(cb, arguments);
                done = true;
            });
        });
        waitsFor(function() {
            return done;
        });
    });
}

describe("Data", function() {

    requireDependencies([ "components/systemConfig/model/data" ], function(_Data) {
        Data = _Data;
    });

    it("Its value can be updated", function() {
        expect(Data).not.toBeNull();
    });

});

Everything works fine when I run mvn jasmine:bdd ; however when I run mvn test, the html unit runner seems to looks for the 'data.js' file under the 'target' folder ; obviously it's not there, and I get
a stack trace :

Exception class=[net.sourceforge.htmlunit.corejs.javascript.WrappedException]
com.gargoylesoftware.htmlunit.ScriptException: Wrapped java.lang.RuntimeException: java.io.FileNotFoundException: /home/phtrivier/...(redacted)../my-project/target/jasmine/src/main/resources/web/resources/components/systemConfig/model/data.js (No such file or directory)
    at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:595)
    at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:537)
    at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:538)
    at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:545)
    at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:520)
    at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:896)
    at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptFunctionJob.runJavaScript(JavaScriptFunctionJob.java:53)
    at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutionJob.run(JavaScriptExecutionJob.java:84)
    at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:313)
    at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutor.run(JavaScriptExecutor.java:148)
    at java.lang.Thread.run(Thread.java:662)

Does the RequireJs runner assumes that the sources are copied to target ? or should another dependency phase take care of it ?

Thanks

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

No branches or pull requests

1 participant