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

Travis and Package.json - Issue running Karma/Testacular #72

Closed
jeme opened this issue Apr 3, 2013 · 8 comments
Closed

Travis and Package.json - Issue running Karma/Testacular #72

jeme opened this issue Apr 3, 2013 · 8 comments

Comments

@jeme
Copy link
Contributor

jeme commented Apr 3, 2013

I have added a Travis build file, so it would run CI on the ui-router.

However, currently the Grunt-file appears to have some issues, but I wan't to just waive over before I replace the "test" task in there with what I use here:

https://github.com/dotJEM/angular-routing/blob/master/gruntfile.js

As you notice some way down, all I do is:

        karma: {
            unit: {
                configFile: 'test-grunt-config.js',
                runnerPort: 9999,
                singleRun: true,
                browsers: ['PhantomJS']
            }
        },

Is there any reason for the way the test tasks are written in the grunt-file... @ksperling I suppose your the one who can answer that question?

On a side-note, I updated the Package.json and set @ksperling as author while the rest of AngularUI as contributors. Not sure if that would sit unwell with some, but I thought that so far he had done most of the code.

EDIT:

I think I have managed to capture the essence of your "dev" task @ksperling, so that it now just uses the grunt-karma task, which is a bit easier to define for us... This is however not the most effective way of doing it as noted here by @vojtajina from Angular/Karma: karma-runner/grunt-karma#3

They do mention an example here: https://github.com/karma-runner/grunt-karma/blob/master/README.md#karma-server-with-auto-runs-on-file-change

Which should allow the karma server to run in the background as a child process and let us run the build watch in grunt... But I couldn't get his example to work.

Is that something you can verify?

@0x-r4bbit
Copy link
Contributor

+1 for switching from testacular to karma. If we get this on the road, we can also close #62 . I'd suggest to use singleRun: true in grunt test task, to ensure that the test are processed only once. While developing on ui-router one should use karma itself on the command line. So that there are two watch tasks pending. grunt watch and karma start.

I'm using this kind of flow in much other project and it worked quite well so far. So, what do you think?

@jeme
Copy link
Contributor Author

jeme commented Apr 3, 2013

@PascalPrecht That is what I do at my own project, and I think that the current test-config is mostly run-able like that, it uses the default browser however which is chrome, I prefer to use PhantomJS for convenience.

What the dev target in grunt does in addition is to build the project, and tests are still run on the source... In my own case when testing after a build with grunt I choose to do it on the output... But in any case... Right now, with this change I think we have effectively switched to Karma... Just need @ksperling to verify and see if there is missing something.

Oh and yes, grunt-karma is run with "SingleRun" mode atm at least...

@ksperling
Copy link
Contributor

@jeme thanks for working on this!

I pretty much copied the original grunt file from the main angular-ui repo, so I can't really comment on why any details are the way they are.

Getting Travis running would definitely be great, I personally don't care about the exact mechanics of grunt vs karma doing the watching during the equivalent of the current "grunt dev".

One reason I like running tests on the source files during dev is that line numbers in stack traces are usable directly to go in and fix things. During a release it would be nice to run on the final .js (and maybe even .min.js)

Just gave your changes a whirl and it's working nicely. Two questions

  • any particular reason for removing 'connect' from grunt dev? I think being able to play around with the sample app to test changes manually is quite helpful.
  • it's helpful in dev mode to run the tests in a real browser so that it's possible to drop in a breakpoints and step through the code. Can you explain how to make this work in the new setup?

@jeme
Copy link
Contributor Author

jeme commented Apr 4, 2013

@ksperling No problem, and that is exactly why I raised this ticket, to see if there was parts I was missing.

The reason why I removed the connect was actually because I couldn't see what it did, and thought it was tied to your implementation of the testacular/karma run. But there is absolutely not problem in adding it again. (And I have done that)

I Never really debugged using the testacular/karma as i felt it became to troublesome ones you crossed a certain boundary, currently I have 100+ tests, and it really just ends up being annoying... For now I have prepared a "karma:debug" configuration which is meant to target your scenario, but It is currently the same as unit except it uses Chrome, and that doesn't give you the ability to debug. We need to get the scenario mentioned in the grunt-karma example to work for this I think, but that is currently stalled on a bug: karma-runner/grunt-karma#14

Since the above is a pull request made 5 hours ago, ill just wait until the weekend, see if that doesn't get pulled in and then try again with the background option to see if that doesn't fix things... Hope it can wait that long?

@jeme
Copy link
Contributor Author

jeme commented Apr 4, 2013

Ones they fix: karma-runner/grunt-karma#15

We should be good to go after another commit, so you are able to debug again.. At least that runs Karma with a browser window and all, so I think you should be able to at least?

@ksperling
Copy link
Contributor

Sounds good

@jeme
Copy link
Contributor Author

jeme commented Apr 6, 2013

This should now be in place, so after updating to grunt-karma 0.4.3, you should be able to debug running grunt dev

@jeme
Copy link
Contributor Author

jeme commented Apr 6, 2013

I removed the tasks that was commented out as well (b3eac35), so I think we can close this one.

@jeme jeme closed this as completed Apr 6, 2013
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

3 participants