nightwatch icon indicating copy to clipboard operation
nightwatch copied to clipboard

V2.1.7 - Any failure while running tests on parallel throw an error `TypeError: Cannot read properties of undefined (reading 'indexOf')` and don't continue to global hooks

Open mostmentor opened this issue 2 years ago • 3 comments

Describe the bug

This error is thrown whenever a failure occurs while running tests in parallel. This occurred only after we update to latest version 2.1.7 I was using 2.0.6 and everything was fine

TypeError: Cannot read properties of undefined (reading 'indexOf') 
       at Array.reduce (<anonymous>) 
       at Array.reduce (<anonymous>)
       at Array.reduce (<anonymous>)

The tests are not continuing to afterEach() hooks in the global file. This is a major issue as we are not able to get actual results from regressions we run using nightwatch. Also the error is not descriptive enough and not showing where exactly we should look at. We are using src_folder to pass all paths to tests

Sample test

sampleTest1.js

// Please add the sample test here

it("sample step", function(browser) {
  browser.assert.equal(true, false);
})
sampleTest2.js

// Please add the sample test here

it("parallel step", function(browser) {
  browser.assert.equal(true, false);
})

Run with command

$ nightwatch

Verbose output

debug.log

 ℹ Connected to ChromeDriver on port 9515 (1642ms).
 Using: chrome (101.0.4951.67) on WINDOWS.

  Received session with ID: 65308eccfee7f57a4b896bd84512029c 
  
  → Running [before]:
  → Completed [before].



   Running sample step:
 ───────────────────────────────────────────────────────────────────────────────────────────────────
  → Running [beforeEach]:
 → Completed [beforeEach].
  
  → Running command: assert.equal () 
 × Failed [equal]: (true == false) - expected "false" but got: "true" (10ms)
     at C:\Users\memam\Documents\hierarchy-manager-browserstack\t1.js:8:18
  → Completed command: assert.equal () (1ms)
 → Running [afterEach]:
  → Completed [afterEach].
 × t1.js\t1.js [Hierarchy Manager Browserstack\t1] sample step
    Failed [equal]: (true == false) - expected "false" but got: "true" (10ms)
        at C:\Users\memam\Documents\hierarchy-manager-browserstack\t1.js:8:18
 → Running [after]:
  → Completed [after].
 Attempting to close session 65308eccfee7f57a4b896bd84512029c...
  
  → Running command: end () 
  
  → Running command: session ('delete', [Function]) 
   Request DELETE /session/65308eccfee7f57a4b896bd84512029c  
   Response 200 DELETE /session/65308eccfee7f57a4b896bd84512029c (24ms) 
 { value: null }
  → Completed command: end () (38ms)
  → Completed command: session ('delete', [Function]) (28ms)
  TypeError: Cannot read properties of undefined (reading 'indexOf')
        at Array.reduce (<anonymous>) 
        at Array.reduce (<anonymous>)
        at Array.reduce (<anonymous>) 
 
TEST FAILURE (2.619s):
   - 1 error during execution;

Configuration

nightwatch.json

const settings = {
     "src_folders": [
          "./sampleTest2.js",
          "./sampleTest1.js"
     ],
     "page_objects_path": [
          "./page_object"
     ],
     "globals_path": "globals.js",
     "webdriver": {
          "keep_alive": true
     },
     "custom_commands_path": [
          "./lib/custom_commands",
          "./node_modules/nightwatch-xhr/es5/commands"
     ],
     "custom_assertions_path": [
          "./node_modules/nightwatch-xhr/es5/assertions"
     ],
     "test_workers": {
          "enabled": true,
          "workers": 8
     },
     "test_settings": {
          "default": {
               "localOption": true,
               "videoRecorder": false,
               "skip_testcases_on_fail": false,
               "end_session_on_fail": false,
               "disable_error_log": false,
               "launch_url": "https://nightwatchjs.org",
               "screenshots": {
                    "enabled": false,
                    "path": "screens",
                    "on_failure": true
               },
               "desiredCapabilities": {
                    "browserName": "chrome"
               },
               "webdriver": {
                    "port": 9515,
                    "start_process": true,
                    "server_path": "node_modules/chromedriver/lib/chromedriver/chromedriver.exe"
               }
          }
     },
     "live_output": true,
     "detailed_output": true,
     "test_runner": {
          "type": "default",
          "options": {
               "bail": false,
               "retries": 0
          }
     }
}
    module.exports = new Promise(resolve => {
      resolve(settings);
    });
                  

Your Environment

Executable Version
nightwatch --version 2.1.7
npm --version 8.5.0
yarn --version 1.22.17
node --version 16.14.2
Browser driver Version
NAME VERSION
OS Version
NAME VERSION

mostmentor avatar May 19 '22 19:05 mostmentor

Thanks for your report, we'll look into it.

beatfactor avatar May 20 '22 07:05 beatfactor

This issue is similar to #3163. I will have a look

gravityvi avatar May 27 '22 05:05 gravityvi

Any progress here ? I'm blocked from using new versions of nightwatch

mostmentor avatar Jun 28 '22 21:06 mostmentor

@gravityvi can you test, I think this is fixed.

AutomatedTester avatar Sep 27 '22 10:09 AutomatedTester

This has been fixed in #3213

gravityvi avatar Sep 27 '22 12:09 gravityvi