Yeoman, Karma and e2e testing

Imagine my surprise when i first looked at the Gruntfile.js of my newly generated angular app and found out that Yeoman is configuring by default only the karma:unit section, missing out the karma:e2e piece. I know the product is fairly new, but i would expect it to be a little more “mature” (spent quite some time figuring out why my e2e tests aren’t working and how to solve the problem).


Anyway, in order to run your e2e tests, you have to do the following:

  1. Update the Gruntfile.js
karma: {
    e2e: {
        configFile: 'karma-e2e.conf.js'
    unit: { ... }
  1. Update the karma-e2e.conf.js
urlRoot = '/e2e/';
proxies = {
    // port has to be the same your web server is running on
    '/': 'http://localhost:9000'


Also, if you want Grunt to run your e2e tests without the need to manually run the web server first, you can additionally define the following task:

grunt.registerTask('test:e2e', function () {[


(and “test:unit” task accordingly, for consistency sake):

grunt.registerTask('test:unit', [

Tagged: , , ,

5 thoughts on “Yeoman, Karma and e2e testing

  1. mattster2002tvv October 17, 2013 at 11:42 pm Reply

    Thanks a bunch mate! This helped me fix my tests!

  2. Nelson Omuto December 16, 2013 at 1:35 am Reply

    thanks dude, this was awesome

  3. tbertet April 2, 2014 at 2:36 pm Reply

    Hi, Thanks for your post. I tried what you said but it seems the ‘test’ server (according to default Gruntfile.js) is listenning to port 9001 and not 9000.

    I changed the port number from 9000 to 9001 and it worked nicely.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: