browserstack / nightwatch-browserstack

Selenium examples for Nightwatch and BrowserStack Automate
https://www.browserstack.com
77 stars 62 forks source link

Can't run tests against BrowserStack using Nightwatch v1.0.19 #28

Closed 9av1n-j0hn50n closed 5 years ago

9av1n-j0hn50n commented 5 years ago

Hi,

I'm in the process of upgrading my Nightwatch package from 0.9.21 to 1.0.19.

I'm having issues running the tests against BrowserStack I'm made all the amends to my BrowserStack config (see below) mentioned here

const sharedConfig = require('./shared.conf')

const browserstackConfig = {
  selenium: {
    start_process: false,
  },

  test_settings: {
    default: {
      selenium_host: 'hub-cloud.browserstack.com',
      selenium_port: 80,
      launch_url: 'http://v09.nightwatchjs.org/',
      desiredCapabilities: {
        project: 'nightwatchGuide',
        build: 'localTesting',
        'browserstack.user': process.env.BROWSERSTACK_ACCESS_USER,
        'browserstack.key': process.env.BROWSERSTACK_ACCESS_KEY,
        'browserstack.local': true,
      },
    },

    chrome: {
      desiredCapabilities: {
        browser: 'Chrome',
        browser_version: '71.0',
      },
    },

    edge: {
      desiredCapabilities: {
        os: 'Windows',
        os_version: '10',
        browser: 'Edge',
        browser_version: '17.0',
      },
    },

    firefox: {
      desiredCapabilities: {
        browser: 'Firefox',
        browser_version: '64.0',
      },
    },
  }
}

for (const i in browserstackConfig.test_settings) {
  const config = browserstackConfig.test_settings[i]
  config['selenium_host'] = browserstackConfig.selenium.host
  config['selenium_port'] = browserstackConfig.selenium.port
  config['desiredCapabilities'] = config['desiredCapabilities'] || {}
}

module.exports = Object.assign({}, sharedConfig, browserstackConfig)

But upon running the tests I get the following in my terminal:

export BROWSERSTACK_ACCESS_USER=user_here && export BROWSERSTACK_ACCESS_KEY=key_here && yarn test:browserstack
yarn run v1.13.0
$ node test/functional/scripts/local.runner.js --config test/functional/config/browserstack.conf.js --env chrome,edge,firefox --suiteRetries 3
Connecting local
Connected. Now testing...
   Cannot create property 'enabled' on boolean 'true'
       at /Users/gavinjohnson/projects/uk-content-nightwatch-guide/test/functional/scripts/local.runner.js:19:10
       at /Users/gavinjohnson/projects/uk-content-nightwatch-guide/test/functional/scripts/local.runner.js:17:16
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Please see my slightly modified local.runner.js script for more detail:

#!/usr/bin/env node

const Nightwatch = require('nightwatch')
const browserstack = require('browserstack-local')
let bs_local

try {
  process.mainModule.filename = './node_modules/.bin/nightwatch'
  console.log('\nconnecting to browserstack')
  Nightwatch.bs_local = bs_local = new browserstack.Local()
  bs_local.start({ key: process.env.BROWSERSTACK_ACCESS_KEY, '--force-local': '--force-local' }, error => {
    if (error) throw error
    console.log('\nconnected to browserstack\n\ntests are now running against the following browsers:')
    Nightwatch.cli((argv) => {
      Nightwatch.CliRunner(argv)
        .setup(null, () => {
          process.kill(bs_local.pid)
        })
        .runTests(() => {
          process.kill(bs_local.pid)
        })
    })
  })
} catch (ex) {
  console.log('\nthere was an error whilst starting the test runner:')
  process.stderr.write(ex.stack + '\n')
  process.exit(2)
}

This method had worked before the Nightwatch update and as far as I can see I've followed their instructions.

Please also see my dependencies below:

  "devDependencies": {
    "browserstack-local": "^1.4.0",
    "chromedriver": "^74.0.0",
    "geckodriver": "^1.16.2",
    "nightwatch": "^1.0.19",
    "selenium-server-standalone-jar": "^3.141.5"
  }

Any help here would be massively appreciated.

Thanks!