最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - jasmineNodeOpts: Unexpected identifier error while executing protractor protractorConfig.js - Stack Overflow

matteradmin7PV0评论

This is my config.js file -

//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 mand line report.
  }
};

I get this error when I try to execute my tests using this config.js file -

C:\TRUNK\tests\func\gui\protractor\config\protractorConfig.js:60
  jasmineNodeOpts: {
  ^^^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
    at Module._pile (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._pile (module.js:456:26)

When I execute protractor --help I get following options -

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.

Please suggest what mistake I'm making in the config file or do I need to configure some more things.

This is my config.js file -

//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 mand line report.
  }
};

I get this error when I try to execute my tests using this config.js file -

C:\TRUNK\tests\func\gui\protractor\config\protractorConfig.js:60
  jasmineNodeOpts: {
  ^^^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
    at Module._pile (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._pile (module.js:456:26)

When I execute protractor --help I get following options -

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.

Please suggest what mistake I'm making in the config file or do I need to configure some more things.

Share Improve this question edited Apr 2, 2014 at 7:02 Piyush Jajoo asked Apr 2, 2014 at 6:55 Piyush JajooPiyush Jajoo 1,0932 gold badges18 silver badges27 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

You forgot a ma at the end of baseUrl: serverConfig.BASE_URL ;)

It should be:

baseUrl: serverConfig.BASE_URL,

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far