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

jasmine:bdd uses jetty, but jasmine:test uses file system #36

Closed
dehru opened this issue Sep 28, 2011 · 9 comments

Comments

@dehru
Copy link

commented Sep 28, 2011

Searls,

BTW, I've just finished using jasmine:bdd for a couple days with a Ext JS 4 application and love it. It works great. I do have an issue with jasmine:test. It is probably specific to Ext JS 4 and likely won't affect others.

It appears that during jasmine:bdd, Jetty delivers the files over http://. But during jasmine:test, the files are delivered as file:/

mvn jasmine:bdd
<script type="text/javascript" src="../../src/main/webapp/app.js"></script>

mvn jasmine:test
<script type="text/javascript" src="file:/Users/admin/workspace/git/ibis/ucas-webapp/target/jasmine/src/app.js"></script>

This gets in the way of the ext dynamic loading...I guess because of Same Origin Policy with the browsers...they don't like file:/ protocol. I understand that it's not your goal to make this work for Ext JS 4. But I just wanted to make sure that you are indeed writing the Spec scripts with the file:/ protocol and this is not a bug.

Cheers,
Dehru

@searls

This comment has been minimized.

Copy link
Owner

commented Nov 1, 2011

Apologies for not getting back to you -- jetty was added to the project only very recently. Prior to that I really didn't want to add a server at all, which is why jasmine:test (still) loads scripts over the file protocol.

However, HtmlUnit seems to really not care about the AJAX over file:/, in fact I've seen several projects that perform AJAX locally. It's probably the case that extjs includes some edge case that HtmlUnit can't handle.

In any case, hopefully in the near future I'll be able to address this by spinning up Jetty again for jasmine:test and making the executor pluggable.

@gantaa

This comment has been minimized.

Copy link

commented Nov 2, 2011

I am having the same problem. When running mvn jasmine:test, the files are deployed to my project's /target/jasmine/src and /target/jasmine/spec directories. When running mvn jasmine:bdd, The files are deployed to jetty with the relative path from the root of my webapp. ie: localhost:8234/web/WEB-INF/js-src and localhost:8234/web/WEB-INF/js-test. Because I am using requireJS with a configuration that points to paths, I am required to add the plugin twice to my pom to do mvn builds and TDD. One configuration for the bdd goal that excludes the test goal config file, and one configuration for test that excludes the bdd goal config file. Can I have different excludes for different goals in one pom plugin declaration? Here is a snippet from my resulting pom:

     <plugins>
           <plugin>
                <groupId>com.github.searls</groupId>
                <artifactId>jasmine-maven-plugin</artifactId>
                <version>1.0.2-beta-5</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <jsSrcDir>web/WEB-INF/js-src</jsSrcDir>
                    <jsTestSrcDir>web/WEB-INF/js-test</jsTestSrcDir>
                    <customRunnerTemplate>web/WEB-INF/js-test/jasmine-template.html</customRunnerTemplate>
                    <specExcludes>
                        <exclude>**/*Test.js</exclude>
                        <exclude>**/jasmine-bdd-test-config.js</exclude>
                    </specExcludes>
                    <sourceExcludes>
                        <exclude>LNM-Main.js</exclude>
                        <exclude>jasmine-config.js</exclude>
                        <exclude>factory.js</exclude>
                        <exclude>control/*.js</exclude>
                        <exclude>model/*.js</exclude>
                        <exclude>view/*.js</exclude>
                    </sourceExcludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.searls</groupId>
                <artifactId>jasmine-maven-plugin</artifactId>
                <version>1.0.2-beta-5</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>bdd</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <jsSrcDir>web/WEB-INF/js-src</jsSrcDir>
                    <jsTestSrcDir>web/WEB-INF/js-test</jsTestSrcDir>
                    <customRunnerTemplate>web/WEB-INF/js-test/jasmine-template.html</customRunnerTemplate>
                    <specExcludes>
                        <exclude>**/*Test.js</exclude>
                        <exclude>**/jasmine-mvn-test-config.js</exclude>
                    </specExcludes>
                    <sourceExcludes>
                        <exclude>LNM-Main.js</exclude>
                        <exclude>jasmine-config.js</exclude>
                        <exclude>factory.js</exclude>
                        <exclude>control/*.js</exclude>
                        <exclude>model/*.js</exclude>
                        <exclude>view/*.js</exclude>
                    </sourceExcludes>
                </configuration>
            </plugin>
     </plugins>
@dehru

This comment has been minimized.

Copy link
Author

commented Nov 2, 2011

gantaa,
Whether this is the right way to use profiles or not, I am using profiles to configure the plugin differently. I still don't have jasmine:test working like I want yet, but am doing a lot of bdd now. So when I run jasmine, I just pass in the profile to mvn like

mvn jasmine:bdd -PjasmineBdd
or
mvn jasmine:test -PjasmineTest

@johanhaleby

This comment has been minimized.

Copy link

commented Apr 17, 2012

I've written a blog on how to work-around this issue. You can read it here: http://blog.jayway.com/2012/04/17/configuring-jasmine-to-work-with-maven-and-jquery-fixtures/

@searls

This comment has been minimized.

Copy link
Owner

commented Apr 17, 2012

@johanhaleby Part of the reason I don't care to spend much time on this issue is that I don't believe unit tests should read from the file system or talk over the network; if they don't, this isn't an issue, right? Is anyone experiencing problems for reasons other than this?

In particular, I think jasmine-jquery's functionality of loading fixtures from external files is a really bad idea and would suggest folks set up their fixtures within their specs (to do so succinctly, I wrote jasmine-fixture).

@dehru

This comment has been minimized.

Copy link
Author

commented Apr 17, 2012

@searls - Early in the project when I was integrating Jasmine and Extjs we really only worked in "development mode". During development mode, Extjs loads it's hundreds of components dynamically depending on what's required. This works great with jasmine:bdd but not with jasmine:test because of the "file:" protocol issue.

This may NOT be a problem for us now that we have finally implemented "production mode" and all our javascript gets aggregated and doesn't use any dynamic loading of components. So I'm thinking jasmine:test running our aggregated/compressed javascript should be fine. I'll let you know.

@searls

This comment has been minimized.

Copy link
Owner

commented Apr 17, 2012

@dehru so Extjs's dependency loading mechanism was the culprit? I've never really used it—is flicking on "production mode" a non-trivial thing for an extjs user to do?

@dehru

This comment has been minimized.

Copy link
Author

commented Apr 17, 2012

@searls - If memory serves me correctly from 7 months ago I think I determined that was the culprit. In order to turn on production mode, Sencha (creators of Extjs) provide a build tool which we had not integrated yet at the time I originally posted this. I wouldn't say it's non-trivial for an extjs user, but I would expect every production Extjs app to integrate it early in development. I'm hoping next week I can try to resurrect jasmine:test from the dead on this project and let you know if that has solved our problem.

@klieber

This comment has been minimized.

Copy link
Collaborator

commented Feb 23, 2013

This should now be resolved by pull request #145

@klieber klieber closed this Feb 23, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.