Reputation: 13
I have written some BDD tests in cypress using cucumber and using below command to run my automation tests:
./node_modules/.bin/cypress-tags run -e TAGS='not @ignore and @bdd',allure=true test:all
As I have 1 tests with @bdd tag so it runs it and shows other 3 tests from feature file as Pending
As I have integration with mochawesome and allure both shows Pending tests in corresponding HTML report as well.
Is there any way to skip|remove these tests (Pending and Skipped) from HTML reports
Here is my mochawesome config
Upvotes: 0
Views: 2208
Reputation: 32118
The on('after:run')
hook can be used to modify the stats displayed in the header, including the chart.
It's not perfect but may suit your requirement.
cypress.config.js
const { defineConfig } = require('cypress');
const { beforeRunHook, afterRunHook } = require('cypress-mochawesome-reporter/lib');
const { removePendingSkipped } = require('./remove-pending-skipped-from-report');
module.exports = defineConfig({
reporter: 'cypress-mochawesome-reporter',
reporterOptions: {
reportDir: 'test-report',
... // other options
},
e2e: {
setupNodeEvents(on, config) {
on('before:run', async (details) => {
await beforeRunHook(details);
});
on('after:run', async () => {
removePendingSkipped(config)
await afterRunHook();
});
},
},
});
remove-pending-skipped-from-report.js
const path = require('path');
const fs = require('fs-extra')
function removePendingSkipped(config) {
const jsonPath = path.join(config.reporterOptions.reportDir , '/.jsons', '\mochawesome.json');
const report = fs.readJsonSync(jsonPath)
const topSuite = report.results[0].suites[0]
remove(topSuite)
fs.writeJsonSync(jsonPath, report)
}
function remove(suite, level = 0) {
const childSuites = suite.suites.map(child => remove(child, ++level))
suite.pending = []
suite.skipped = []
return suite
}
module.exports = {
removePendingSkipped
}
Upvotes: 2