MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / CustomReporter

Function CustomReporter

src/test/web/customReporter.ts:212–313  ·  view source on GitHub ↗
(this: any, runner: mochaTypes.Runner, options: mochaTypes.MochaOptions)

Source from the content-addressed store, hash-verified

210let mochaInternalsLoaded = false;
211
212function 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 })

Callers

nothing calls this directly

Calls 7

requireFunction · 0.85
writeReportProgressFunction · 0.85
formatExceptionFunction · 0.85
hijackMethod · 0.80
onMethod · 0.65
onceMethod · 0.65
releaseMethod · 0.45

Tested by

no test coverage detected