Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel Execution fails with Mocha as a runner #3894

Closed
gravityvi opened this issue Aug 23, 2023 Discussed in #3892 · 5 comments · Fixed by #3904
Closed

Parallel Execution fails with Mocha as a runner #3894

gravityvi opened this issue Aug 23, 2023 Discussed in #3892 · 5 comments · Fixed by #3904
Assignees
Labels
bug mocha Issues related to Mocha test runner p1

Comments

@gravityvi
Copy link
Member

Discussed in #3892

Originally posted by anupamtomar August 22, 2023
While Executing the single .js file $ npm run test -- Test\test-cases\basicoperation.js command getting the below error, I debugged and checked with console.log too, execution is just going inside the 'describe' suite but not inside the test 'it', by the time it reaches to test 'it', it got failed at first place and gives the below error in the console, moreover I have mentioned the 'before' hook inside the 'describe' suite but it is bypassing the before hook as well.

Can someone please help me out here?

Error
   unhandledRejection: this.client.reporter.setCurrentSection is not a function
TypeError: this.client.reporter.setCurrentSection is not a function
    at TestSuite.runGlobalHook (C:\someuser\VSTS_Repository\someProject\node_modules\nightwatch\dist\testsuite\index.js:380:30)
    at TestSuite.onTestSuiteFinished (C:\someuser\VSTS_Repository\someProject\node_modules\nightwatch\dist\testsuite\index.js:489:21)   
    at onSuiteFinished (C:\someuser\VSTS_Repository\someProject\node_modules\nightwatch\dist\runner\test-runners\mocha\custom-runner.js:39:35)
    at CustomRunner.runSuite (C:\someuser\VSTS_Repository\someProject\node_modules\nightwatch\dist\runner\test-runners\mocha\custom-runner.js:62:20)

when trying to run a folder (Multiple .js files) $ npm run test -- Test\test-cases command then getting the below kind of console response-

Running   default: Test\test-cases\basicoperation.js  
Running   default: Test\test-cases\test.js  
┌ ────────────────── ×  default: Test\test-cases\basicoperation.js  ┐
│                                                                          │
│                                                                          │
│                                                                          │
└──────────────────────────────────────────────────────────────────────────┘
┌ ────────────────── ×  default: Test\test-cases\test.js  ┐
│                                                                │
│                                                                │
│                                                                │
└────────────────────────────────────────────────────────────────┘

Please find the relevant details below-

Node Version - v18.14.2
npm version - 9.5.0
Java version - java 11.0.12 2021-07-20 LTS

//package.json
...
"scripts": {
    "test": "nightwatch",
  },
"dependencies": {
    "@nightwatch/selenium-server": "^3.150.0",
    "chromedriver": "^116.0.0",
    "nightwatch": "^3.1.3",
    ...
  },
...
//nightwatch.conf.js

const seleniumHost = 'localhost';
const chromeDriverPath = require('chromedriver').path;
const seleniumJarPath = require('@nightwatch/selenium-server').path;

module.exports = {
  src_folders: ['Test/test-cases'],
  custom_commands_path: [''],
  custom_assertions_path: [''],
  plugins: [],
  globals_path: '',
  output_folder: "reports",

  webdriver: {},

  test_workers: {
    enabled: true,
    workers: process.env.TEST_WORKERS || 2
  },

  test_settings: {
    default: {
      disable_error_log: false,
      launch_url: 'http://localhost',

      screenshots: {
        enabled: true,
        path: 'screenshots',
        on_failure: true
      },

      desiredCapabilities: {
        browserName: 'chrome'
      },

      webdriver: {
        start_process: true,
        server_path: seleniumJarPath ,
        host: seleniumHost,
        port: 4445,
        cli_args: {
            'webdriver.chrome.driver': chromeDriverPath,
        } 
      },

      test_runner: {
        type : 'mocha',
        options : {
          ui : 'bdd',
        }
      }
    },

  },

};
```</div>
@gravityvi
Copy link
Member Author

Hey @anupamtomar, Thanks for raising this issue. I've identified this issue it is only occurring when using mocha as a test-runner. Just for my understanding, is there a reason to prefer mocha as a runner over the default runner?

@gravityvi gravityvi added bug p1 mocha Issues related to Mocha test runner labels Aug 23, 2023
@anupamtomar
Copy link

Hi @gravityvi, preferred mocha due to its few potential benefits, nothing major. moreover, for BDD test syntax, Custom Test Hooks, Flexible Test Configuration and etc.

@anupamtomar
Copy link

hi @gravityvi, May I know if there is any progress on that?

@gravityvi
Copy link
Member Author

gravityvi commented Sep 1, 2023

Hey @anupamtomar, could you check if the PR resolves the issue?

@anupamtomar
Copy link

Hi @gravityvi, I am Still facing the same issue, but FYI, I have checked the same project in Other Systems, and it is working fine, and was working fine before the fix too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mocha Issues related to Mocha test runner p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants