“E / launcher - 错误:TypeError:模块不是函数”量角器测试

时间:2017-09-08 16:20:40

标签: angularjs protractor karma-mocha

我无法配置我的量角器测试。

我收到以下错误:

| 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

规范文件:

'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配置:

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'
    ]
});
};

量角器配置:

//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
    },
};

我知道有类似的问题,但他们的答案都不适合我。

我已经研究过的建议:

(1)角度模拟是否包含在angular.js之后的文件数组中?

Yessir。你可以在我的karma.config

中确认

(2)你的角度模拟和角度是否相同。

是的。版本1.6.6

(3)Angular和Jasmine版本可能没有jive。

我用Google搜索并用Google搜索并用Google搜索,但我无法确定哪些版本与其他版本一起使用。以下是我正在使用的内容:

AngularJS 1.6.6

Jasmine 2.8.0

Mocha 3.5.0

量角器5.1.2

任何建议,无论多么牵强,都会受到赞赏。我已经被困了一段时间了。感谢

0 个答案:

没有答案