0

I'm trying to mock the backend so that I can write some e2e tests.

I searched online but I can't figure out what i'm doing wrong. I get this error on the first line of my code:

angular is not defined.

My protractor config file is:

exports.config = {
    specs: ['tests/e2e/*.js'],
    baseUrl: "http://localhost:8100/#/",
    framework: 'jasmine',
    allScriptsTimeout: 5000000,
    capabilities: {
        'browserName': 'chrome'
    },
    onPrepare: function () {
        browser.driver.get(browser.baseUrl);
        var SpecReporter = require('jasmine-spec-reporter');
        jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));
    },
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 300000,
        includeStackTrace: true,
        print: function () {
        }
    }
};

and the very start of my e2e test is:

'use strict';
describe('Page', function() {
  var BY, test;
  BY = by;
  test = angular.module('hgApp', ['ionic', 'ngMockE2E']);
  return test.run(function($httpBackend) {
    return console.log($httpBackend);
  });
});

What am I doing wrong? Thanks for any help

EDIT

I also added browser.waitForAngular() before trying to do beforeEach module but still nothing, same error as before

Nick
  • 13,493
  • 8
  • 51
  • 98
  • And what do you have at `http://localhost:8100/#/` ? Karma config has nothing to do with Protractor and e2e, it isn't taken into account. If Angular isn't loaded on `http://localhost:8100/#/`, it will be undefined. – Estus Flask Aug 01 '16 at 10:05
  • I'm using ionic, and that's the app main path – Nick Aug 01 '16 at 10:28
  • I've added browser.waitForAngular() but still get the same error and I can't figure out why – Nick Aug 01 '16 at 10:46
  • `browser.waitForAngular` waits for Angular application. In your case `angular` global is undefined. I'm afraid nobody except you can figure out how Angular is being loaded in your app. – Estus Flask Aug 01 '16 at 11:59

0 Answers0