searls / jasmine-maven-plugin

Maven plugin to execute Jasmine Specs. Creates your HTML runners for you, runs headlessly, outputs JUnit XML
http://searls.github.io/jasmine-maven-plugin
Other
290 stars 163 forks source link

jQuery 1.9.1 breaks jasmine-maven-plugin #178

Closed punkisdead closed 11 years ago

punkisdead commented 11 years ago

I upgraded our project from jQuery 1.8.0 to 1.9.1 and running the tests in the browser using mvn jasmine:bdd works just fine, but when running mvn jasmine:test it fails with the following errors:

[INFO] 
[INFO] --- jacoco-maven-plugin:0.6.2.201302030002:report (post-test) @ top-ui ---
[INFO] 
[INFO] --- jasmine-maven-plugin:1.3.1.2:test (default) @ top-ui ---
2013-05-02 14:26:54.325:INFO:oejs.Server:jetty-8.1.10.v20130312
2013-05-02 14:26:54.368:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:58509
[INFO] Executing Jasmine Specs
May 02, 2013 2:26:57 PM com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter runtimeError
SEVERE: runtimeError: message=[An invalid or illegal selector was specified (selector: '*,:x' error: Invalid selector: *:x).] sourceName=[http://localhost:58509/src/main/webapp/assets/3rd-party/jquery/1.9.1/jquery.min.js] line=[4] lineSource=[null] lineOffset=[0]
May 02, 2013 2:26:58 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'http://localhost:58509/' [12:52] Error in style rule. (Invalid token "*". Was expecting one of: , , , "}", ";".)
May 02, 2013 2:26:58 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: 'http://localhost:58509/' [12:52] Ignoring the following declarations in this rule.
May 02, 2013 2:26:58 PM com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter runtimeError
SEVERE: runtimeError: message=[An invalid or illegal selector was specified (selector: '[id='parent-dropdown'] :selected' error: Invalid selector: *[id="parent-dropdown"] *:selected).] sourceName=[http://localhost:58509/src/main/webapp/assets/3rd-party/jquery/1.9.1/jquery.min.js] line=[4] lineSource=[null] lineOffset=[0]
May 02, 2013 2:26:58 PM com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter runtimeError
SEVERE: runtimeError: message=[An invalid or illegal selector was specified (selector: '[id='parent-dropdown'] :selected' error: Invalid selector: *[id="parent-dropdown"] *:selected).] sourceName=[http://localhost:58509/src/main/webapp/assets/3rd-party/jquery/1.9.1/jquery.min.js] line=[4] lineSource=[null] lineOffset=[0]
May 02, 2013 2:26:58 PM com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter runtimeError
SEVERE: runtimeError: message=[An invalid or illegal selector was specified (selector: '[id='parent-dropdown'] :selected' error: Invalid selector: *[id="parent-dropdown"] *:selected).] sourceName=[http://localhost:58509/src/main/webapp/assets/3rd-party/jquery/1.9.1/jquery.min.js] line=[4] lineSource=[null] lineOffset=[0]

Using jasmine-maven-plugin version 1.3.1.2, and selenium-htmlunit version 2.32.0

mprins commented 11 years ago

this really is s a htmlunit problem, not a jasmine problem, try and see if you can use the phantomjs runner: http://searls.github.io/jasmine-maven-plugin/phantomjs.html

or mabe try a different browser emulation for htmlunit, eg. CHROME

mathieubodin commented 11 years ago

Hi, I'm facing the same kind of problem with the following configuration and jQuery JavaScript Library v1.10.2:

<plugin>
   <groupId>com.github.searls</groupId>
   <artifactId>jasmine-maven-plugin</artifactId>
   <version>1.3.1.2</version>
   <executions>
      <execution>
          <goals>
             <goal>test</goal>
          </goals>
      </execution>
   </executions>
   <dependencies>
      <dependency>
          <groupId>net.sourceforge.htmlunit</groupId>
           <artifactId>htmlunit</artifactId>
           <version>2.12</version>
      </dependency>
   </dependencies>
…
</plugin>

Could you explain how to "try a different browser emulation for htmlunit, eg. CHROME" with an example or pointing the documentation ?

Note that running "mvn jasmine:bdd" works like a charm

pimlottc commented 11 years ago

Could you explain how to "try a different browser emulation for htmlunit, eg. CHROME" with an example or pointing the documentation ?

It looks like you do it by adding a browserVersion tag to your jasmin-maven-plugin block:

<configuration>
  <browserVersion>CHROME</browserVersion>
</configuration>

However, that does not seem to be compatible with jquery at all (tried 1.8.0, 1.8.3, 1.9.0, 1.9.1, 1.10.2, 2.0.0, 2.0.3), e.g. (w/ 2.0.3):

net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot find function addEventListener in object [object HTMLDocument]. (http://localhost:55267/src/lib/jquery-2.0.3.js#834)

pimlottc commented 11 years ago

Realted HtmlUnit bug seems to be https://sourceforge.net/p/htmlunit/bugs/1536/

pimlottc commented 11 years ago

I did some testing of different settings, on both 1.x and 2.x jQuery releases (versions 1.8.0, 1.8.3, 1.9.0, 1.9.1, 1.10.2, 2.0.0, 2.0.3)

  • CHROME: All failed
  • FIREFOX_3_6: Worked through 1.8.3; failed for 1.9.0 and above, and 2.x
  • FIREFOX_17: Same as FIREFOX_3_6
  • INTERNET_EXPLORER_8: Worked for all versions of 1.x (up to current release 1.10.2); failed for 2.x
  • INTERNET_EXPLORER_9: Same as INTERNET_EXPLORER_8
klieber commented 11 years ago

@pimlottc There really isn't anything I can do about HtmlUnit's deficiencies. This is exactly why we added support for using phantomjs in place of HtmlUnit.

We are on the latest version of HtmlUnit so if you are experiencing issues you should really be sending them to the HtmlUnit team so they can fix the issues in the next version.

I'm going to go ahead and close this issue since in my opinion it has been fixed now that we support phantomjs.

pimlottc commented 11 years ago

I understand that, I just wanted to document what does and doesn't work currently. Especially since HtmlUnit is the "out of the box" default solution, and a large part of using jasmine-maven-plugin is to be able to take advantage of the maven repository system. PhantomJS is a good fallback, but having to setup and maintain an external platform-dependent binary negates much of the benefit in using a maven-based solution.

I know it's a tough situation since HtmlUnit is not really in your control but unfortunately it has a large influence in the usefulness of jasmine-maven-plugin. I will definitely try to work with the HtmlUnit team in getting this resolved, but I've got a bit to learn about it first.

pimlottc commented 11 years ago

There's been some good progress on issue HtmlUnit-1536, looks like this may be fixed in the next release!

nhajratw commented 11 years ago

@punkisdead I got this to work by using phantomjs per @klieber's comment.