Getting e2e testing working in Angular.js
Inexplicably, you may have discovered that the Yeoman karma-generator only configures your application for specs/unit tests by default.
To get integration/e2e tests up and running, you'll need to do the following:
Add an e2e block in Gruntfile.js:
karma: {
   e2e: {
    configFile: 'karma-e2e.conf.js'
   },
   unit: {
     configFile: 'karma.conf.js',
     singleRun: true
   }
 },Add the following to karma-e2e.conf.js:
 proxies = {
   // change this if you've changed your grunt server port. default is 9000
   '/': 'http://localhost:9000' 
};
 urlRoot = '/__e2e/';If you want your integration tests running continuously, ensure singleRun is false and autoWatch is true.
Finally, ensure you wrap your tests in a beforeEach:
describe("E2E Tests", function() {
  beforeEach(function() {
    browser().navigateTo('/');
  });
  it('should navigate to somewhere fancy', function() {
     foo();
  });
});To get the test server going, now simply run:
grunt karma:e2eNo doubt this will be rectified in upcoming releases, but it does seem like an odd omission.
Written by Bayard Randel
Related protips
1 Response
 
Thanks for the post! and don't forget to spin up the the app server itself at localhost:9000 :)
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
 #Testing 
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#
 
 
 
 
