Requirejs 量角器+;安魂曲

Requirejs 量角器+;安魂曲,requirejs,protractor,Requirejs,Protractor,请告诉我如何在RequireJS中使用量角器 代码工作 var dentalConfig = require('./conf/dentalConfig.js'); var login = require('./pages/login.js'); exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub', baseUrl: dentalConfig.baseUrl, specs: [

请告诉我如何在RequireJS中使用量角器

代码工作

var dentalConfig = require('./conf/dentalConfig.js');
var login = require('./pages/login.js');    
exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    baseUrl: dentalConfig.baseUrl,
    specs: [
        'pages/company.js'
    ],
    onPrepare: function () {
        login();
    }
};
但是如果我将exports.config放在requirejs()中 量角器投掷误差:

c:\Users\UserName\AppData\Roaming\npm\node_modules\protractor\lib\configParser.js:184
fileConfig.configDir = path.dirname(filePath);
TypeError: Cannot set property 'configDir' of undefined.
这不管用

var requirejs = require('requirejs');    
requirejs.config({
    baseUrl: './',
    nodeRequire: require
});    
requirejs([
        'conf/dentalConfig',
        'pages/login'
    ],
    function (dentalConfig, login) {
        exports.config = {
            seleniumAddress: 'http://localhost:4444/wd/hub',
            baseUrl: dentalConfig.baseUrl,
            specs: [
                'pages/company.js'
            ],
            onPrepare: function () {
                login();
            }
        };
    }
);

您的配置文件应该如下所示。。 exports.config={

     seleniumAddress: 'http://localhost:4444/wd/hub',
     directConnect: true,
     framework: 'jasmine',

     specs: ['TestScript name that has to be executed.js'],


     jasmineNodeOpts: {
            showColors: true,
            defaultTimeoutInterval: 30000,
            isVerbose:true,
            includeStackTrace:true
        },


     capabilities: {
         'browserName': 'chrome',


     },

}

不!在这个答案中,需要在浏览器端使用JS,但我不会在服务器端使用它进行量角器测试。这很公平。但问题是你的标题和提问方式设置了错误的基调。现在有一个问题:为什么在服务器中使用RequireJS?为什么不?RequireJS在NodeJS上运行良好,我喜欢它的AMD格式,为什么不呢?因为如果你不需要把事情复杂化,为什么还要把事情复杂化呢?我确实在Node中使用RequireJS来测试我的一些模块。然而,除非我必须使用它,否则我不会使用它。例如,很有可能。(在您提问之前,让我指出与RequireJS相比,
amd loader
是一个非常简单的模块加载器。)您使用的是什么版本的量角器?您是否看到控制台上记录的任何其他错误?