Test Suite blocks (`describeAndIt`) are repeated in the report
Closed this issue · 21 comments
Description
When I'm executing nesting describeAndIt
blocks then in the master report, Test Suite blocks are repeated.
For e.g.
describe('Suite 1', () => {
describe('Suite 2', () => {
it('test 1', async () => {
utility.logMessage('test 1 block');
});
it('test 2', async () => {
utility.logMessage('test 2 block');
});
});
describe('Suite 3', () => {
it('test 3', async () => {
utility.logMessage('test 3 block');
});
});
});
Spec Reporter
Master Report (wdio-html-nice-reporter
)
"wdio-html-nice-reporter": "^7.8.5",
"@rpii/wdio-report-events" : "^0.1.4"
master-report.zip
Please find the json report
Hello @rpii
Did you get a chance to check this json report?
Sure thanks!
Having the same issue, test results are repeating in the reports.
Hello @rpii ,
We debugged the code to find the root cause of this issue and noticed that even for nested suites (describe
block inside describe
block), the code was adding a separate entry into the reports.suites
array. Hence, duplicate entries for nested suites were getting generated in the master-report
.
We added a condition in createReport()
function of reportAggregator.ts
to check if the suite
does not have any parent then only proceed further. And this worked absolutely fine.
I have raised a PR Fix duplicate suites in the Master report.
Could you please check the PR
cc: @abime
Hi @rpii ,
Thanks for checking the code.
I ran below spec file to fix this issue:
describe('Suite 1', () => {
describe('Suite 2', () => {
it('test 1', async () => {
console.log('test 1 block');
});
it('test 2', async () => {
console.log('test 2 block');
});
});
describe('Suite 3', () => {
it('test 3', async () => {
console.log('test 3 block');
});
describe('Suite 4', () => {
describe('Suite 5', () => {
it('test 5', async() => {
console.log('test 5 block');
});
});
});
});
});
Hi @rpii ,
We do not use mocharc.json. Instead we use package.json.
Let us know if you need any further information on analyzing the issue.
{
"name": "test-automation",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"prepare": "husky install"
},
"keywords": [],
"author": "",
"license": "ISC",
"imports": {
"#lib": "./lib/index.js",
"#testdata": "./testdata/index.js"
},
"dependencies": {
"@rpii/wdio-report-events": "^0.1.4",
"@wdio/cli": "^7.7.4",
"@wdio/reporter": "^7.7.5",
"moment": "^2.29.1",
"properties-reader": "^2.2.0",
"string-format": "^2.0.0",
"wdio-html-nice-reporter": "^7.8.5"
},
"devDependencies": {
"@babel/cli": "^7.14.5",
"@babel/core": "^7.14.6",
"@babel/preset-env": "^7.14.7",
"@babel/register": "^7.14.5",
"@wdio/local-runner": "^7.7.4",
"@wdio/mocha-framework": "^7.7.4",
"@wdio/spec-reporter": "^7.7.3",
"chai": "^4.3.4",
"chromedriver": "^96.0.0",
"husky": "^7.0.1",
"lint-staged": "^12.0.2",
"prettier": "2.3.2",
"wdio-chromedriver-service": "^7.2.0"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
}
}
Thanks @rpii ,
@mayankshukla94 and I can collaborate for this and check if the issue is fixed.
Hi @rpii
It is working fine.
Thanks for your help!
You can consider closing this PR https://github.com/rpii/wdio-html-reporter/pull/76 as the issue is already fixed.
cc: @abime
Ok great. thanks for all the collaboratio.