(this: any, runner: mochaTypes.Runner, options: mochaTypes.MochaOptions)
| 210 | let mochaInternalsLoaded = false; |
| 211 | |
| 212 | function CustomReporter(this: any, runner: mochaTypes.Runner, options: mochaTypes.MochaOptions) { |
| 213 | if (!mochaInternalsLoaded) { |
| 214 | // Use synchronous require for mocha internals |
| 215 | // eslint-disable-next-line @typescript-eslint/no-var-requires |
| 216 | const mochaUtils = require('mocha/lib/utils'); |
| 217 | // eslint-disable-next-line @typescript-eslint/no-var-requires |
| 218 | defaultReporter = require('mocha/lib/reporters/spec'); |
| 219 | mochaUtils.inherits(CustomReporter, defaultReporter); |
| 220 | mochaInternalsLoaded = true; |
| 221 | } |
| 222 | defaultReporter.call(this, runner, options); |
| 223 | // eslint-disable-next-line @typescript-eslint/no-use-before-define |
| 224 | runner |
| 225 | .once(constants.EVENT_RUN_BEGIN, () => { |
| 226 | consoleHijacker.release(); |
| 227 | void writeReportProgress({ event: constants.EVENT_RUN_BEGIN }); |
| 228 | }) |
| 229 | .once(constants.EVENT_RUN_END, () => { |
| 230 | consoleHijacker.release(); |
| 231 | void writeReportProgress({ event: constants.EVENT_RUN_END, stats: runner.stats }); |
| 232 | }) |
| 233 | .on(constants.EVENT_SUITE_BEGIN, (suite: mochaTypes.Suite) => { |
| 234 | consoleHijacker.release(); |
| 235 | void writeReportProgress({ |
| 236 | event: constants.EVENT_SUITE_BEGIN, |
| 237 | title: suite.title, |
| 238 | titlePath: suite.titlePath(), |
| 239 | fullTitle: suite.fullTitle(), |
| 240 | time: Date.now() |
| 241 | }); |
| 242 | }) |
| 243 | .on(constants.EVENT_SUITE_END, (suite: mochaTypes.Suite) => { |
| 244 | consoleHijacker.release(); |
| 245 | void writeReportProgress({ |
| 246 | event: constants.EVENT_SUITE_END, |
| 247 | title: suite.title, |
| 248 | titlePath: suite.titlePath(), |
| 249 | slow: suite.slow(), |
| 250 | fullTitle: suite.fullTitle(), |
| 251 | time: Date.now() |
| 252 | }); |
| 253 | }) |
| 254 | .on(constants.EVENT_TEST_FAIL, (test: mochaTypes.Test, err: any) => { |
| 255 | const consoleOutput = consoleHijacker.release(); |
| 256 | void writeReportProgress({ |
| 257 | event: constants.EVENT_TEST_FAIL, |
| 258 | title: test.title, |
| 259 | err: formatException(err), |
| 260 | titlePath: test.titlePath(), |
| 261 | slow: test.slow(), |
| 262 | fullTitle: test.fullTitle(), |
| 263 | consoleOutput, |
| 264 | duration: test.duration, |
| 265 | state: test.state, |
| 266 | isPending: test.isPending(), |
| 267 | parent: { fullTitle: test.parent?.fullTitle() } |
| 268 | }); |
| 269 | }) |
nothing calls this directly
no test coverage detected