CodeceptJS
CodeceptJS copied to clipboard
CodeceptJS: Allure report always opens the latest report - Multiple Browser Execution
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?



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'
}
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.
@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.
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
@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.
Generating Report: allure serve ./allure-results
Which generates report of either edge or chrome and not both
hey @myrepojuly1987 oh I see you're using the run-multiple
which is kinda obsolete, may you try using run-workers
?
@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?
@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.
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.
Hello… @StasGrishaevTutu … sure, will share it tomorrow without fail…
@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 much appreciated for quick response !
@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…