import * as CypressNpmApi from "cypress" ; import { slackRunner } from "cypress-slack-reporter/bin/slack/slack-alert" ; const marge = require ( "mochawesome-report-generator" ) ; const { merge } = require ( "mochawesome-merge" ) ; CypressNpmApi . run ( { reporter : "cypress-multi-reporters" , reporterOptions : { reporterEnabled : "mocha-junit-reporter, mochawesome" , mochaJunitReporterReporterOptions : { mochaFile : "cypress/reports/junit/test_results[hash].xml" , toConsole : false } , mochawesomeReporterOptions : { reportDir : "cypress/reports/mocha" , quiet : true , overwrite : true , html : false , json : true } } } ) . then ( async ( results ) => { const generatedReport = await Promise . resolve ( generateReport ( { reportDir : "cypress/reports/mocha" , inline : true , saveJson : true , } ) ) ; console . log ( "Merged report available here:-" , generatedReport ) ; return generatedReport ; } ) . then ( generatedReport => { const base = process . env . PWD || "." ; const program = { ciProvider : "circleci" , videoDir : `${ base }/cypress/videos` , vcsProvider : "github" , screenshotDir : `${ base }/cypress/screenshots` , verbose : true , reportDir : `${ base }/cypress/reports/mocha` } ; const ciProvider = program . ciProvider ; const vcsProvider = program . vcsProvider ; const reportDirectory = program . reportDir ; const videoDirectory = program . videoDir ; const screenshotDirectory = program . screenshotDir ; const verbose = program . verbose ; console . log ( "Constructing Slack message with the following options" , { ciProvider , vcsProvider , reportDirectory , videoDirectory , screenshotDirectory , verbose } ) ; const slack = slackRunner ( ciProvider , vcsProvider , reportDirectory , videoDirectory , screenshotDirectory , verbose ) ; console . log ( "Finished slack upload" ) ; } ) . catch ( ( err ) => { console . log ( err ) ; } ) ; function generateReport ( options ) { return merge ( options ) . then ( ( report ) => marge . create ( report , options ) ) ; }