angularjs - e2e mocked backend

85 views Asked by At

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

0

There are 0 answers