Keep getting TypeError: config.suite.split is not a function when running regression tests

ⅰ亾dé卋堺 提交于 2020-08-11 03:42:37

问题


I got the following error when running a sample regression test:

TypeError: config.suite.split is not a function

Here is the the configuration file. It looks ok but I must have missed something but I can't honestly find what it could be.

Configuration.js file (this was working few days ago)

var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['PageObjectLocator2.js'],
  capabilities: {
    browserName: 'chrome'
  },

  onPrepare: function() {
      browser.driver.manage().window().maximize(); 

      jasmine.getEnv().addReporter(
                new Jasmine2HtmlReporter({
                  savePath: 'target/screenshots'
                })
              );




  },// end of onPrepare

  suite:
      {
      Smoke  : ['ChainLocator.js','dropDowns.js'],
      Regression : 'nonAnuglarSpec.js'

      },



//Options to be passed to Jasmine-node.
  jasmineNodeOpts: {
    showColors: true, // Use colors in the command line report.
  }

}

This is the package.json file. Could the issues here but honestly don't know

{
  "name": "LocatorTraining",

  "dependencies": {

"protractor":  "^5.4.1",
"jasmine-data-provider": "^2.2.0",
"protractor-jasmine2-html-reporter":"^0.0.7"



  },


  "scripts": {

 "webdriver-update": "./node_modules/.bin/webdriver-manager update",
"webdriver-start": "./node_modules/.bin/webdriver-manager start",
"protractor": "./node_modules/.bin/protractor configurations.js",
"SmokeTest": "./node_modules/.bin/protractor configurations.js  --suite Smoke",
"RegressionTest": "./node_modules/.bin/protractor configurations.js  --suite Regression",

 "start": "npm run webdriver-update && npm run webdriver-start"

  }

}

Message from termaminal.

Jacquelines-MacBook-Air:LocatorTraining jacquelinegeorge$ npm run RegressionTest

> LocatorTraining@ RegressionTest /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining
> protractor configurations.js  --suite Regression

/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:155
                throw e;
                ^

TypeError: config.suite.split is not a function
    at Function.getSpecs (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/configParser.js:86:26)
    at new TaskScheduler (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/taskScheduler.js:34:100)
    at helper.runFilenameOrFn_.then.then.then (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/launcher.js:175:25)
    at _fulfilled (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:834:54)
    at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:863:30
    at Promise.promise.promiseDispatch (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:796:13)
    at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:604:44
    at runSingle (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:137:13)
    at flush (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:125:13)
    at internalTickCallback (internal/process/next_tick.js:70:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! LocatorTraining@ RegressionTest: `protractor configurations.js  --suite Regression`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the LocatorTraining@ RegressionTest script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jacquelinegeorge/.npm/_logs/2018-11-07T14_32_24_804Z-debug.log

modifying suite to 'suites' did fix part of the problem. However got the following error message:

[21:38:02] I/launcher - Running 1 instances of WebDriver
[21:38:02] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
Started
F

Failures:
1) Opening non Angular website Opening google page
  Message:
    WebDriverError: unknown error: failed to change window state to maximized, current state is normal
      (Session info: chrome=70.0.3538.77)
      (Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)
  Stack:
    WebDriverError: unknown error: failed to change window state to maximized, current state is normal
      (Session info: chrome=70.0.3538.77)
      (Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)
        at Object.checkLegacyResponse (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/error.js:546:15)
        at parseHttpResponse (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/http.js:509:13)
        at doSend.then.response (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/http.js:441:30)
        at process.internalTickCallback (internal/process/next_tick.js:77:7)
    From: Task: WebDriver.manage().window().maximize()
        at thenableWebDriverProxy.schedule (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
        at Window.maximize (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/webdriver.js:1686:25)
        at onPrepare (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/configurations.js:11:37)
        at q_1.Promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/util.js:46:49)
        at Function.promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:682:9)
        at Object.runFilenameOrFn_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/util.js:38:16)
        at plugins_.onPrepare.then (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/runner.js:98:27)
        at _fulfilled (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:834:54)
        at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:863:30
        at Promise.promise.promiseDispatch (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:796:13)

1 spec, 1 failure
Finished in 0.143 seconds


[21:38:06] I/launcher - 0 instance(s) of WebDriver still running
[21:38:06] I/launcher - chrome #01 failed 1 test(s)
[21:38:06] I/launcher - overall: 1 failed spec(s)
[21:38:06] E/launcher - Process exited with error code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! LocatorTraining@ RegressionTest: `protractor configurations.js  --suite Regression`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the LocatorTraining@ RegressionTest script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jacquelinegeorge/.npm/_logs/2018-11-07T21_38_06_831Z-debug.log
Jacquelines-MacBook-Air:LocatorTraining jacquelinegeorge$ 

回答1:


Just as https://www.protractortest.org/#/page-objects suggests your config's suites must be plural, not suite

However in cmd line, you should use --suite (not --suites) to give the suite name you defined in suites block in your config file.




回答2:


suite:
{
    Smoke  : ['ChainLocator.js','dropDowns.js'],
    Regression : 'nonAnuglarSpec.js'
},

suite is an plaint object, and those don't have a split method. This would imply that you've specified an invalid/unexpected type for suite.



来源:https://stackoverflow.com/questions/53191629/keep-getting-typeerror-config-suite-split-is-not-a-function-when-running-regres

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!