"E/launcher - Error: TypeError: module is not a function" protractor testing

422 Views Asked by At

I'm having trouble getting my protractor tests configured.

I get the following error:

| 304 => protractor src/test/protractor.conf.js
[11:22:52] I/launcher - Running 1 instances of WebDriver
[11:22:52] I/local - Starting selenium standalone server...
[11:22:52] I/local - Selenium standalone server started at             
http://10.0.0.89:53657/wd/hub
[11:22:53] E/launcher - Error: TypeError: module is not a function
    at Suite.<anonymous> (/Users/sms97admin/Bolt/ng-    
bolt/src/test/components/textfieldTODO.mocha.js:11:16)
    at Object.create     
(/usr/local/lib/node_modules/mocha/lib/interfaces/common.js:114:19)
    at context.describe.context.context     
(/usr/local/lib/node_modules/mocha/lib/interfaces/bdd.js:44:27)
    at Object.<anonymous> (/Users/sms97admin/Bolt/ng-
bolt/src/test/components/textfieldTODO.mocha.js:2:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
[11:22:53] E/launcher - Process exited with error code 100

Spec File:

'use strict';
describe('Textfield still needs testing', function() {

beforeEach(function() {
    angular.module('blt_config', []);
    angular.module('blt_dataRoutes', []);
    angular.module('blt_appProfile', []);
    angular.module('blt_appViews', []);
});

beforeEach(module('blt_core', function($provide) {
    $provide.value('config', { defaultLogLevel: "error", debug: true });
}));

beforeEach(module('truncate'));
beforeEach(module('blt_textfield'));
beforeEach(module('templates'));

var element;
var outerScope;
var innerScope;

beforeEach(inject(function($rootScope, $compile) {
    element = angular.element('<form><blt-textfield ' +
        'data-model="value" ' +
        'data-name="{{name}}" ' +
        'data-label="{{label}}" ' +
    '></blt-textfield></form>');

    outerScope = $rootScope;
    $compile(element)(outerScope);

    innerScope = element.isolateScope();
    outerScope.$digest();
}));

describe('misc tests', function() {

    it.only('has to pass', function() {
        expect(12).to.equal(12);
    });
});

Karma Config:

module.exports = function(config) {
config.set({
    basePath: '../',
    files: [
        // Dependencies
        '../node_modules/angular/angular.js',
        '../node_modules/angular-route/angular-route.js',
        '../node_modules/angular-mocks/angular-mocks.js',
        '../node_modules/angular-truncate-2/src/angular-truncate-2.js',
        '../node_modules/angular-animate/angular-animate.js',

        // Load Definitions
        // NOTE: These Must Load First
        'core/js/ng-bolt.js',
        'core/js/core.module.js',
        'components/datepicker/datepicker.module.js',
        'components/view/view.module.js',

        // Load All Other Files
        'core/js/**.js',
        'components/**/*.js',

        // Load Templates
        'components/**/*.template.html',

        // Load Tests
        'test/**/**.mocha.js'
    ],
    exclude: [
        // JSDoc Files
        'core/**/*.jsdoc.js',
        'components/**/*.jsdoc.js'
    ],
    autoWatch: true,
    frameworks: ['mocha', 'sinon-chai'],
    browsers: ['Chrome'],
    client: {
        mocha: {
            reporter: 'html'
        }
    },
    preprocessors: {
        'components/**/*.template.html': ['ng-html2js']
    },
    ngHtml2JsPreprocessor: {
        moduleName: 'templates'
    },
    plugins: [
        'karma-chrome-launcher',
        'karma-firefox-launcher',
        'karma-mocha',
        'karma-sinon-chai',
        'karma-ng-html2js-preprocessor'
    ]
});
};

Protractor Config:

//jshint strict: false
exports.config = {
    allScriptsTimeout: 11000,
    specs: [
        //'*.js'
        'components/textfieldTODO.mocha.js'
    ],

    capabilities: {
        'browserName': 'chrome'
    },

    baseUrl: 'http://localhost:8000/',
    framework: 'mocha',

    jasmineNodeOpts: {
        defaultTimeoutInterval: 30000
    },
};

I know there are similar questions but none of their answers work for me.

SO suggestions I have looked into:

(1) Is angular-mocks included in file array after angular.js?

Yessir. You can confirm it in my karma.config

(2) Are your angular-mocks and angular the same version.

Yep. Version 1.6.6

(3) Angular and Jasmine versions might not jive.

I googled and googled and googled but I can't ascertain which versions go with which others. Here's what I'm working with:

AngularJS 1.6.6

Jasmine 2.8.0

Mocha 3.5.0

Protractor 5.1.2

Any suggestion, no matter how farfetched would be appreciated. I've been stuck for quite some time. Thanks

0

There are 0 best solutions below