Radosław Andraszyk
Radosław Andraszyk

Reputation: 450

CoreUi - why nightwatch cannot run e2e tests?

I want to start working with CoreUi Admin template and create project containing unit and e2e testing.

In the begining, I install CoreUi like shown in documentation:

git clone https://github.com/coreui/coreui-free-vue-admin-template.git CoreUI-Vue
cd CoreUI-Vue
npm install

Everything is ok. Now I want to run whole unit and e2e tests:

npm run test:unit   
npm run test:e2e

All unit tests run properly. But when I run e2e test I got the following errors:

> @coreui/[email protected] test:e2e
> vue-cli-service test:e2e

 INFO  Starting development server...
[BABEL] Note: The code generator has deoptimised the styling of /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/@coreui/vue/dist/coreui-vue.common.js as it exceeds the max of 500KB.


 WARNING  Compiled with 2 warnings                                                                                                                                                                       2:47:38 PM
 warning

asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
  css/app.10fee0d6.css (383 KiB)                                                                                                                                                                                     js/chunk-28d6db65.e7636129.js (488 KiB)
  js/chunk-2d0a400c.650c6f3a.js (3.37 MiB)                                                                                                                                                                           js/chunk-2d0ae5e6.22010046.js (390 KiB)
  js/chunk-2d237b34.468fc7b7.js (1.36 MiB)
  js/chunk-vendors.03b8fe62.js (687 KiB)

 warning

entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
  app (1.07 MiB)
      js/chunk-vendors.03b8fe62.js
      css/app.10fee0d6.css
      js/app.94002fbe.js


                                                                                                                                                                                                                     App running at:
  - Local:   http://localhost:8080/
  - Network: http://172.31.33.121:8080/

  App is served in production mode.
  Note this is for preview or E2E testing only.

 INFO  Running end-to-end tests ...

[Test] Test Suite
=================
⚠ Error connecting to localhost on port 9515.
_________________________________________________
TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (348ms)

 ✖ test
   An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
    at endReadableNT (_stream_readable.js:1201:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

  Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."                                                                                                    at endReadableNT (_stream_readable.js:1201:12)
       at processTicksAndRejections (internal/process/task_queues.js:84:21)

   SKIPPED:
   - CoreUI Vue e2e tests

 ERROR  Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/@vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/@vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
    at makeError (/home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:174:9)
    at /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:278:16
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
bagsiur@DESKTOP-718MBR1:~/Projects/B2B/test-coreui/CoreUI-Vue$
bagsiur@DESKTOP-718MBR1:~/Projects/B2B/test-coreui/CoreUI-Vue$ npm run test:e2e

> @coreui/[email protected] test:e2e
> vue-cli-service test:e2e

 INFO  Starting development server...


 WARNING  Compiled with 2 warnings                                                                                                                                                                       3:06:39 PM
 warning

asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
  css/app.10fee0d6.css (383 KiB)
  js/chunk-28d6db65.e7636129.js (488 KiB)
  js/chunk-2d0a400c.650c6f3a.js (3.37 MiB)
  js/chunk-2d0ae5e6.22010046.js (390 KiB)
  js/chunk-2d237b34.468fc7b7.js (1.36 MiB)
  js/chunk-vendors.03b8fe62.js (687 KiB)

 warning
entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
  app (1.07 MiB)
      js/chunk-vendors.03b8fe62.js
      css/app.10fee0d6.css
      js/app.94002fbe.js



  App running at:
  - Local:   http://localhost:8080/
  - Network: http://172.31.33.121:8080/

  App is served in production mode.
  Note this is for preview or E2E testing only.                                                                                                                                                                    
 INFO  Running end-to-end tests ...                                                                                                                                                                                
[Test] Test Suite
=================
⚠ Error connecting to localhost on port 9515.
_________________________________________________

TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (348ms)

 ✖ test
   An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
    at endReadableNT (_stream_readable.js:1201:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

  Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."                                                                                                    at endReadableNT (_stream_readable.js:1201:12)
       at processTicksAndRejections (internal/process/task_queues.js:84:21)

   SKIPPED:
   - CoreUI Vue e2e tests

 ERROR  Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/@vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/@vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
    at makeError (/home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:174:9)
    at /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

I work on wsl2 and Debian. My node.js version is v13.14.0 and npm is 7.12.1. I installed chromedriver in version: ChromeDriver 2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706) and last stable google chrome: google-chrome-stable 90.0.4430.212-1

What do I miss? Where could be the cause of the error in running e2e tests?

@UPDATE: I put the configuration of Nightwatch.conf.json:

// http://nightwatchjs.org/gettingstarted#settings-file

const path = require('path')
const deepmerge = require('deepmerge')
const chromedriver = require('chromedriver')

// user may have not installed geckodriver
let geckodriver = {}
try {
  geckodriver = require('geckodriver')
} catch (e) {}

const userOptions = JSON.parse(process.env.VUE_NIGHTWATCH_USER_OPTIONS || '{}')
const useSelenium = process.env.VUE_NIGHTWATCH_USE_SELENIUM === '1'
const startHeadless = process.env.VUE_NIGHTWATCH_HEADLESS === '1'
const concurrentMode = process.env.VUE_NIGHTWATCH_CONCURRENT === '1'
const chromeArgs = []
const geckoArgs = []

if (startHeadless) {
  chromeArgs.push('headless')
  geckoArgs.push('--headless')
}

const defaultSettings = {
  src_folders: ['tests/e2e/specs'],
  output_folder: 'tests/e2e/reports',
  page_objects_path: 'tests/e2e/page-objects',
  custom_assertions_path: 'tests/e2e/custom-assertions',
  custom_commands_path: 'tests/e2e/custom-commands',
  globals_path: path.resolve('tests/e2e/globals.js'),
  test_workers: concurrentMode,
  test_settings: {
    default: {
      detailed_output: !concurrentMode,
      launch_url: '${VUE_DEV_SERVER_URL}'
    },

    chrome: {
      desiredCapabilities: {
        browserName: 'chrome',
        chromeOptions: {
          w3c: false,
          args: chromeArgs
        }
      }
    },

    firefox: {
      desiredCapabilities: {
        browserName: 'firefox',
        alwaysMatch: {
          acceptInsecureCerts: true,
          'moz:firefoxOptions': {
            args: geckoArgs
          }
        }
      },
      webdriver: useSelenium ? {} : {
        server_path: geckodriver.path,
        port: 4444
      }
    }
  }
}

const baseSettings = deepmerge(defaultSettings, webdriverServerSettings())

module.exports = deepmerge(baseSettings, adaptUserSettings(userOptions))

function adaptUserSettings (settings) {
  // The path to nightwatch external globals file needs to be made absolute
  // if it is supplied in an additional config file, due to merging of config files
  if (settings.globals_path) {
    settings.globals_path = path.resolve(settings.globals_path)
  }

  return settings
}

function webdriverServerSettings () {
  if (useSelenium) {
    return {
      selenium: {
        start_process: true,
        host: '127.0.0.1',
        port: 4444,
        server_path: require('selenium-server').path,
        cli_args: {
          'webdriver.chrome.driver': chromedriver.path,
          'webdriver.gecko.driver': geckodriver.path
        }
      }
    }
  }

  return {
    webdriver: {
      start_process: true,
      port: 9515,
      server_path: chromedriver.path
    }
  }
}

Upvotes: 0

Views: 419

Answers (1)

xidedix
xidedix

Reputation: 210

Version mismatch of chromedriver and chrome is the most common reason of e2e failing like this.

  • ChromeDriver 2.41 supports Chrome v67-69
  • your google-chrome-stable 90.0.4430 needs ChromeDriver 90.0.4430

Upvotes: 1

Related Questions