@@ -2,9 +2,20 @@ import Slack from '@slack/bolt'
22const { App } = Slack
33import dotenv from 'dotenv'
44import fs from 'fs'
5+ import { execSync } from 'child_process'
6+ import path from 'path'
57
68dotenv . config ( )
79
10+ // Marge expects meta.marge.options to be an Object; mochawesome leaves it null. Patch before marge.
11+ const reportJsonPath = path . join ( process . cwd ( ) , 'mochawesome-report' , 'mochawesome.json' )
12+ const json = JSON . parse ( fs . readFileSync ( reportJsonPath , 'utf8' ) )
13+ if ( json . meta ?. marge ?. options == null ) {
14+ json . meta . marge . options = { }
15+ fs . writeFileSync ( reportJsonPath , JSON . stringify ( json ) )
16+ }
17+ execSync ( 'marge mochawesome-report/mochawesome.json -f sanity-report.html --inline' , { stdio : 'inherit' , cwd : process . cwd ( ) } )
18+
819const mochawesomeJsonOutput = fs . readFileSync ( './mochawesome-report/mochawesome.json' , 'utf8' )
920const mochawesomeReport = JSON . parse ( mochawesomeJsonOutput )
1021const report = `./mochawesome-report/sanity-report.html`
@@ -58,7 +69,6 @@ async function publishMessage (text, report) {
5869 token : process . env . SLACK_BOT_TOKEN ,
5970 channel_id : process . env . SLACK_CHANNEL_ID ,
6071 initial_comment : '*Here is the report generated*' ,
61- filetype : 'html' ,
6272 filename : 'sanity-report.html' ,
6373 file : fs . createReadStream ( report )
6474 } )
0 commit comments