lundi 1 août 2016

angularjs - e2e mocked backend

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 () {
        }
    }
};

Karma config file is:

module.exports = function (config) {
    config.set({
        basePath: './',
        frameworks: ['jasmine'],
        files: [
            'bower-lib/ionic/js/ionic.bundle.js',
            'bower-lib/angular/angular.js',
            'bower-lib/angular-*/angular-*.js',
            'www-dev/js/*.min.js',
            'www-dev/js/*.js',
            'www-dev/js/app.js',
            'www-dev/js/templates.js''
        ],
        preprocessors: {
            './www-dev/js/app.js': ['coverage']
        },
        reporters: ['coverage'],
        coverageReporter: {
            type : 'html',
            dir : './tests/unit/'
        },
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        client: {
            captureConsole: true
        },
        autoWatch: true,
        browsers: ['Chrome_small'],
        customLaunchers: {
            Chrome_small: {
                base: 'Chrome',
                flags: [
                    '--window-size=400,400',
                    '--window-position=0,0'
                ]
            }
        },
        singleRun: false,
        concurrency: Infinity
    })
}

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

Aucun commentaire:

Enregistrer un commentaire