Configuring Intellij 11.0 to Run the unit tests of the phoneCat tutorial

768 views
Skip to first unread message

carp...@gmail.com

unread,
Mar 23, 2012, 7:56:43 PM3/23/12
to ang...@googlegroups.com
Hello everybody.

I´m new to angular and I´m doing the phoneCat tutorial  ( http://docs.angularjs.org/#!/tutorial ) in intelliJ 11.0

I´ve had quite some trouble configuring intelliJ to run the unit tests so I thought I would share the problems I´ve encountered and how to solve them in case somebody tryies to do the same.

My procedure to do so have been:

1.- Clone the git seed into a local dir (c:/dev)

                 git clone git://github.com/angular/angular-phonecat.git

2.- Create a wep project from scratch in idea and point it to the cloned "angular-phonecat" folder, by doing so, I can run in the git console the 'checkout steps' and have the sources automatically updated in Idea.

3.- I installed Node js on my machine (windows 7 proffesional 64bits), and added the Node plugin to IntelliJ
        Here a screen capture of the conf I´ve used


Just with that simple configuration I was able to run node from my Intellij.

3.- Then I installed the JsTestDriven plugin from Idea following the instructions in: http://confluence.jetbrains.net/display/WI/Installation+of+JsTestDriver+IntelliJ+plugin
  
Here is a screen capture of the the jsTestDriver conf I´ve used.

NOTE: in order to get idea to recognize the second conf file I had to change the name of the 'jsTestDriver-scenario.conf' to 'jsTestDriver-scenario.jstd'

Up to this point I was able to launch the test driver server from intellij and capture a browse, but when I tryied to run the unit tests of the tutorial I started getting problems.

If you try to run the tests with these configurations the console shows an error that says that it can´t find any of the resources to load.

Testing started at 00:01 ...

Cannot read [
C:\dev\angular-phonecat\config\test\lib\angular\angular-scenario.js
] derived from test/lib/angular/angular-scenario.js
Cannot read [
C:\dev\angular-phonecat\config\config\jstd-scenario-adapter-config.js
] derived from config/jstd-scenario-adapter-config.js
Cannot read [
C:\dev\angular-phonecat\config\test\lib\angular\jstd-scenario-adapter.js
] derived from test/lib/angular/jstd-scenario-adapter.js
Cannot read [
C:\dev\angular-phonecat\config\test\e2e\scenarios.js
] derived from test/e2e/scenarios.js
at com.google.jstestdriver.PathResolver.resolve(PathResolver.java:98)
at com.google.jstestdriver.config.ParsedConfiguration.resolvePaths(ParsedConfiguration.java:99)
at com.google.jstestdriver.config.Initializer.initialize(Initializer.java:86)
at com.google.jstestdriver.embedded.JsTestDriverImpl.createRunnerInjector(JsTestDriverImpl.java:368)
at com.google.jstestdriver.embedded.JsTestDriverImpl.runConfigurationWithFlags(JsTestDriverImpl.java:342)
at com.google.jstestdriver.embedded.JsTestDriverImpl.runConfiguration(JsTestDriverImpl.java:233)
...

looking at the route of the files you can see that the routes of the files are wrong. The 'test' folder is not inside of the 'config' folder but next to it (they are 'siblings' so to speak) so I changed the routes inside conf files. 
The resulinting jsTestDriver.conf file looked like this (i did the same with the 'jsTestDriver-scenario.jstd' file)


load:
  - ../test/lib/jasmine/jasmine.js
  - ../test/lib/jasmine-jstd-adapter/JasmineAdapter.js
  - ../app/lib/angular/angular.js
  - ../test/lib/angular/angular-mocks.js
  - ../app/js/*.js
  - ../test/unit/*.js

exclude:

But these time I got no error but this message: 'Unable to attach test reporter to test framework or test framework quit unexpectedly' in the event log.

Searching in google I came across these bug 


There seems to be a problem with relative paths in config since version 1.3.2 in the jsTestDriver

So thenI reverted my changes on the config files and moved both of them to the root folder (c:/dev/angular-phonecat)

But I got the same message on the event log.

After searching in some forums I got to the conclusion that maybe What I needed to do was to update the  jasmine-jstd-adapter to its lates version 
so I downloaded the latest version I could find (ibolmo-jasmine-jstd-adapter-1.1.2-0-g19fc291) and override the jasmineAdapter.js script in the C:\dev\angular-phonecat\test\lib\jasmine-jstd-adapter folder with the new one.

and FINALLY i got the tests of the tutorial to work.
 

Vojta Jína

unread,
Mar 25, 2012, 4:57:33 AM3/25/12
to ang...@googlegroups.com
Hey, thanks for sharing...

Does it work without the plugin (when you execute things from commandline, without IntelliJ) ?
It should. I guess IntelliJ plugin has its own version of JSTD included, which is probably not the latest one.

Btw, we use Misko's fork of Jasmine Adapter: https://github.com/mhevery/jasmine-jstd-adapter

V.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/BgdUih7EP20J.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.

carp...@gmail.com

unread,
Mar 26, 2012, 4:41:15 AM3/26/12
to ang...@googlegroups.com
Yes, from the commandline works perfectly.

thanks for the tip about what jasmin adapter to use. :)

Carlos
V.

To unsubscribe from this group, send email to angular+unsubscribe@​googlegroups.com.

Vojta Jína

unread,
Mar 26, 2012, 4:57:04 AM3/26/12
to ang...@googlegroups.com
Then, the problem is that the plugin uses old jstd.

You can try to find the plugin path and jstd jar file and replace it with latest version. That should solve the issue.

V.

To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/tfWtdZpRMsAJ.

To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.

Carles __

unread,
Mar 26, 2012, 8:59:19 AM3/26/12
to ang...@googlegroups.com

mmm

 

I don´t think the problem is with IntelliJ´s plugin because if I use the Jasmine Adapter from Misko's fork everything works.

And if you look at the jstd plugin note in Intellij it says that is built using JsTestDriver-1.3.4-a witch I thing is the latest version.

 

The problem is probably the opposite, that the tutorial uses an older version of jstd and the jasmine adapter, and that´s the reason it doesn´t work in IntelliJ.

 

Anyways everything works fine if you do the tutorial from the command line. And it is not a change if you want to do the tutorial in Intellij.

 

:) 


Thanks for your comments.


C.


Richard Johnson

unread,
Mar 26, 2012, 12:20:14 PM3/26/12
to AngularJS
I helped a friend get the tutorial working with IntelliJ. We found
that the IntelliJ JsTestDriver plugin uses a newer version of
JsTestDriver that requires an updated Jasmine (http://code.google.com/
p/js-test-driver/issues/detail?id=258#c8). The Angular tutorial
includes older Jasmine and JasmineAdapter releases that need to be
updated. I gave these updated files to my friend in a patch file that
she applies against the tutorial directories.

Changing the config files to be relative to the parent directory
("../") is needed because the IntelliJ JsTestDriver plugin doesn't
support the "--basepath" option that the tutorial scripts use to start
the driver. The Angular tutorial scripts specify the basepath to be
the parent so all config files are relative to the parent. When
running the unit tests under the IntelliJ JsTestDriver, the .conf
files need to be edited as you found.

Rich

Vojta Jína

unread,
Mar 26, 2012, 1:53:14 PM3/26/12
to ang...@googlegroups.com
I'm sorry, I got confused, you are right.

There is an old version of jstd + jasmine adapter in the tutorial.
Igor is currently working on migrating the tutorial to v1.0, it will
have the latest jstd as well as jasmine adapter.

V.

> --
> You received this message because you are subscribed to the Google Groups "AngularJS" group.

Botteu

unread,
May 9, 2012, 9:16:54 AM5/9/12
to ang...@googlegroups.com
With the help from this thread I think I managed to get the tests running. I just ran the jsTestDriver.conf though. When I tried to run jsTestDriver-scenario.conf I got 'Unable to attach test reporter to test framework or test framework quit unexpectedly' . But maybe I'm not supposed to run that? I'm pretty new with both the Jetbrains tools and testing frameworks, so...

But, as I said, when I run jsTestDriver.conf it works (I tested this by writing a failing test).
Reply all
Reply to author
Forward
Message has been deleted
0 new messages