nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.85k stars 1.34k forks source link

Junit XML is overwritten when running parallel envs on same browser #4236

Open mostmentor opened 4 months ago

mostmentor commented 4 months ago

Description of the bug/issue

I'm running a test on multiple envs (dev,qa,stage,...) all on same browser (Chrome). I noticed that only one XML is found at the end of the run because each time the Junit XML is overwritten with same reportPrefix (check here https://github.dev/nightwatchjs/nightwatch/blob/b7339c46ea3eb395ae790ade62061fd7037f836c/lib/reporter/reporters/junit.js#L61 ) I tried to log reportPrefix at the end of the tests and it always has same name reportPrefix: 'CHROME_126.0.6478.127__'

Steps to reproduce

  1. Go to '...'
  2. Click on '...'
  3. Scroll down to '...'
  4. See error

Sample test

No response

Command to run

nigtwatch -e dev,qa

Verbose Output

No response

Nightwatch Configuration

const settings = {
     "src_folders": [
          "tests"
     ],
     "webdriver": {
          "keep_alive": true
     },
     "test_workers": {
          "enabled": true,
          "workers": 5
     },
     "test_settings": {
          "default": {
               "localOption": true,
               "skip_testcases_on_fail": false,
               "end_session_on_fail": false,
               "disable_error_log": false,
               "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"
               }
          },
          "qa": {
               "launch_url": "some_url"
          },
          "dev": {
               "launch_url": "some_url"
          }
     },
     "live_output": true,
     "silent": true,
     "output_folder": "./reports/test-reports/merged",
     "detailed_output": "true",
     "test_runner": {
          "type": "default",
          "options": {
               "bail": false,
               "retries": 0
          }
     }
}
                  module.exports = new Promise(resolve => {
                    resolve(settings);
                  });
                  module.exports.settings = settings

Nightwatch.js Version

3.7.0

Node Version

No response

Browser

No response

Operating System

No response

Additional Information

No response

mostmentor commented 4 months ago

Any updates on this issue ?

garg3133 commented 4 months ago

@mostmentor One way to solve this is to use different output_folder for different envs.

For example:

"test_settings": {
          "default": {
               "localOption": true,
               "skip_testcases_on_fail": false,
               "end_session_on_fail": false,
               "disable_error_log": false,
               "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"
               },
               "reporter_options": {
                 "output_folder": "tests_output/default"
               }
          },
          "qa": {
               "launch_url": "some_url",
               "reporter_options": {
                 "output_folder": "tests_output/qa"
               }
          },
          "dev": {
               "launch_url": "some_url",
               "reporter_options": {
                 "output_folder": "tests_output/dev"
               }
          }
     },
mostmentor commented 4 months ago

@garg3133 It's not working

garg3133 commented 4 months ago

@mostmentor That would mean you already have output_folder set somewhere. Try mentioning output_folder directly inside the envs instead of inside reporter_options, like below:

  "qa": {
       "launch_url": "some_url",
       "output_folder": "tests_output/qa"
  },
  "dev": {
       "launch_url": "some_url",
       "output_folder": "tests_output/dev"
  }
mostmentor commented 3 months ago

@garg3133 This didn't work either. The html,xml and json reports are exported to tests_output When I used --trace the snapshots got added to output/qa and output/dev but the other reports(xml,html,json) are still exported to test_output