jasmineNodeOpts:执行量角器时出现意外的标识符错误.js

jasmineNodeOpts: Unexpected identifier error while executing protractor protractorConfig.js

本文关键字:意外 标识符 错误 js 执行 量角器 jasmineNodeOpts      更新时间:2023-09-26

这是我的配置.js文件 -

//server config information
var serverConfig=require('./serverConfig.js').serverConfig;

var $browser= serverConfig.$browser;
//got the browser name
process.argv.forEach(function (val, index) {
  if(val==='-browser'){
    $browser=process.argv[index+1];
  }
});
// !!! update the server config
serverConfig.$browser=  $browser;
 //config
 //browser.driver.manage().timeouts().setScriptTimeout(TIME_OUT);
// The main suite of Protractor tests.
exports.config = {
  seleniumServerJar: '../../selenium/selenium-server-standalone-2.37.0.jar',
  chromeDriver: '../../selenium/chromedriver.exe',
  seleniumAddress: serverConfig.SELENIUMN_ADDRESS,
  // Spec patterns are relative to this directory.
     specs: [
'../e2e/Regression/CreateOperatorViewFromViewManagement.js' 
    ],

  capabilities: {
    'browserName': $browser
  },
  onPrepare:'../prepareStartup.js',
  //When the angular bootstrap not from the <html></html>
  rootElement: 'body>div',
  baseUrl: serverConfig.BASE_URL 
  jasmineNodeOpts: {
    showColors: true, // Use colors in the command line report.
  }
};

当我尝试使用此配置.js文件执行测试时,我收到此错误 -

C:'TRUNK'tests'func'gui'protractor'config'protractorConfig.js:60
  jasmineNodeOpts: {
  ^^^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at ConfigParser.addFileConfig (C:'Users'user'AppData'Roaming'npm'node_modules'protractor'lib'configParser.js:139:20)
    at Object.init (C:'Users'user'AppData'Roaming'npm'node_modules'protractor'lib'launcher.js:59:7)
    at Object.<anonymous> (C:'Users'user'AppData'Roaming'npm'node_modules'protractor'lib'cli.js:118:23)
    at Module._compile (module.js:456:26)

当我执行量角器时 - 帮助我得到以下选项 -

Options:
  --help                                             Print Protractor help menu
  --version                                          Print Protractor version
  --browser, --capabilities.browserName              Browsername, e.g. chrome or firefox
  --seleniumAddress                                  A running seleium address to use
  --seleniumServerJar                                Location of the standalone selenium jar file
  --seleniumPort                                     Optional port for the selenium standalone ser
  --baseUrl                                          URL to prepend to all relative paths
  --rootElement                                      Element housing ng-app, if not html or body
  --specs                                            Comma-separated list of files to test
  --exclude                                          Comma-separated list of files to exclude
  --verbose, --jasmineNodeOpts.isVerbose             Print full spec names
  --stackTrace, --jasmineNodeOpts.includeStackTrace  Print stack trace on error
  --params                                           Param object to be passed to the tests
  --framework                                        Test framework to use. jasmine or mocha.

请建议我在配置文件中犯了什么错误,或者我是否需要配置更多内容。

您忘记了baseUrl: serverConfig.BASE_URL ;)末尾的逗号

它应该是:

baseUrl: serverConfig.BASE_URL,