CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

CodeceptJS: Allure report always opens the latest report - Multiple Browser Execution

Open myrepojuly1987 opened this issue 2 years ago • 5 comments

What are you trying to achieve?

Trying to execute same tests on different browsers (Chrome and Edge) in parallel and view the test results.

What do you get instead?

CodeceptJS generates 2 reports in the allure-results directory, but always shows the latest report when viewed using allure serve command. Could you please guide me on how to generate a singe report and view the test results executed in both Chrome and Edge?

![image](https://user-images.githubusercontent.com/97806447/182031353-6bb54f3f-0ec2-4155-8565-d8500d2db478.png)

![image](https://user-images.githubusercontent.com/97806447/182031409-f24a484f-3e87-4ddd-bae8-e50bedc964ab.png)

![image](https://user-images.githubusercontent.com/97806447/182032100-dfdeb85c-e910-4ebf-98b6-e460c407b203.png)

Provide test source code if related

Feature('Test Allure report multiple browsers');

Scenario('test something', ({ I }) => {
    I.amOnPage('./');
}).tag('basic');

Details

  • CodeceptJS version: "^3.3.4"
  • NodeJS Version: v16.13.1
  • Operating System: WIndows 10
  • puppeteer || webdriverio || testcafe version (if related): Webdriverio
  • Configuration file:
const { setHeadlessWhen, setCommonPlugins } = require('@codeceptjs/configure');

// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);

// enable all common plugins https://github.com/codeceptjs/configure#setcommonplugins
setCommonPlugins();

exports.config = {
  tests: './webdriver_tests/*_test.js',
  output: './allure-results',
  helpers: {
    WebDriver: {
      url: 'https://docs.qameta.io/allure/#_usage_8',
      browser: 'chrome',
    }
  },
  include: {
    I: './steps_file.js'
  },
  multiple:{
    basic:{
      "browsers": ["chrome", "MicrosoftEdge"],
    },
  },
  plugins: {
    wdio: {
      enabled: true,
      services: ['selenium-standalone'],
    },
    allure: {
      enabled: true,
      outputDir: "./allure-results"
    },
    screenshotOnFail: {
      enabled: true
    },
    stepByStepReport: {
      enabled: true,
      output: "./allure-results"
    },
  },
  bootstrap: null,
  mocha: {},
  name: 'tests'
}

myrepojuly1987 avatar Jul 31 '22 14:07 myrepojuly1987

Hey @myrepojuly1987 if I'm not wrong the allure reports already aggregated all files in results folder to show up the final report for you.

kobenguyent avatar Jul 31 '22 17:07 kobenguyent

@PeterNgTr Thanks for your reply. This is completely a new tool to me and learning a lot about this tool and it is a great one too.

I see the allure-results directory genreated as shown below with one for chrome and the other for edge. image

I am looking to combine these 2 reports into a single report which shows the execution results in both the browsers

Since allure has built-in aggretation functionalty, I tried doing the below but still it generates only one single report (which is either for chrome or edge). Not sure where I am gng wrong here.

allure serve ./allure-results/basic_chrome_1 ./allure-results/basic_edge_2

myrepojuly1987 avatar Jul 31 '22 18:07 myrepojuly1987

@PeterNgTr

Sharing the config again

const { setHeadlessWhen, setCommonPlugins } = require('@codeceptjs/configure');

// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);

// enable all common plugins https://github.com/codeceptjs/configure#setcommonplugins
setCommonPlugins();

exports.config = {
  tests: './webdriver_tests/*_test.js',
  output: './allure-results/',
  helpers: {
    WebDriver: {
      url: 'https://docs.qameta.io/allure/#_usage_8',
      browser: 'chrome'
    }
  },  
  include: {
    I: './steps_file.js'
  },
  multiple:{
    basic:{
      "browsers": [
        {
            browser: "chrome",
            desiredCapabilities:{
               browserName: "chrome", 
            },
         //   outputName: "chrome"
        },
        {
            browser: "MicrosoftEdge",
           // outputName: "edge"
        }
    ]
    },
  },
  plugins: {
    wdio: {
      enabled: true,
      services: ['selenium-standalone'],
    },
    allure: {
      enabled: true,
      outputDir: "./allure-results"
    },
    screenshotOnFail: {
      enabled: true
    },
    stepByStepReport: {
       enabled: true,
       output: "./allure-results"
     },
  },
  bootstrap: null,
  mocha: {},
  name: 'tests'
}

This is the comannd that I am running to run the tests in chrome and edge npx codeceptjs run-multiple basic

Would be great if you can let me know if there is a way to combine the results generated.

image

Generating Report: allure serve ./allure-results Which generates report of either edge or chrome and not both

image

myrepojuly1987 avatar Jul 31 '22 18:07 myrepojuly1987

hey @myrepojuly1987 oh I see you're using the run-multiple which is kinda obsolete, may you try using run-workers?

kobenguyent avatar Aug 01 '22 08:08 kobenguyent

@PeterNgTr Editing my previous post. Was able to set up the parallel.js file and was able to run the workers as stated in https://codecept.io/parallel/#parallel-execution-by-workers

But even then the allure report opened only the latest report. Can you please try it from your end or share example if you have any?

myrepojuly1987 avatar Aug 01 '22 10:08 myrepojuly1987

@PeterNgTr : the issue was with the suite title which was common when I executed it in parallel for both the browsers … Changed the suite title using event suite.before and was able to generate the aggregate allure report. Closing this ticket.

myrepojuly1987 avatar Aug 21 '22 16:08 myrepojuly1987

Changed the suite title using event suite.before and was able to generate the aggregate allure report. Closing this ticket.

@myrepojuly1987 hi there, could you share code, please ? i'm stuck with same issue.

StanislavGrishaev avatar Dec 16 '22 13:12 StanislavGrishaev

Hello… @StasGrishaevTutu … sure, will share it tomorrow without fail…

myrepojuly1987 avatar Dec 16 '22 14:12 myrepojuly1987

@StasGrishaevTutu

Here is the sample. Just ensure the below event gets dispatched as given here https://codecept.io/internal-api/#concepts under 'Event Listeners' section and add the file to the helpers in codecept.conf.js

import { event, config} from 'codeceptjs';

event.dispatcher.on(event.suite.before, function (suite) {
      
    /**
     * Example to fetch the browser name. If executing in multiple test libs then add swtich case for helpers
     * const conf =  config.get();
       const browser = conf.helpers.WebDriver.browser;
     */
    
    const browser = UIHelper.getBrowserName(); //see example above to fetch the browserName
   //modify the suite.title value which is then used by the allure reports
    suite.title = 'Browser' + ': ' + browser.toUpperCase() + ' - ' + suite.title;
  }); 

myrepojuly1987 avatar Dec 16 '22 14:12 myrepojuly1987

@myrepojuly1987 much appreciated for quick response !

StanislavGrishaev avatar Dec 16 '22 15:12 StanislavGrishaev

@StasGrishaevTutu You welcome… just leave a msg here if you are still facing issue in generating the aggregate report…will try to share a sample repo tomorrow…

myrepojuly1987 avatar Dec 16 '22 15:12 myrepojuly1987