MCPcopy Create free account
hub / github.com/PageLeay/celestial-runtime / constructor

Method constructor

reporter.cjs:78–155  ·  view source on GitHub ↗
(runner)

Source from the content-addressed store, hash-verified

76// this reporter outputs test results, indenting two spaces per suite
77class MyReporter {
78 constructor(runner) {
79 this._errors = [ ];
80 this._indents = 1;
81 this._lastLog = getTime();
82 this._lastPass = "";
83 this._lastPrefix = null;
84 this._lastPrefixHeader = null;
85 this._testLogs = [ ];
86 this._suiteLogs = [ ];
87 this._prefixCount = 0;
88 const stats = runner.stats;
89
90 runner.once(EVENT_RUN_BEGIN, () => {
91
92 }).on(EVENT_SUITE_BEGIN, (suite) => {
93 this._suiteLogs.push([ ]);
94 suite._ethersLog = (text) => {
95 this._suiteLogs[this._suiteLogs.length - 1].push(getString(text))
96 };
97 if (suite.title.trim()) {
98 this.log(`<blue+>Suite: ${ escapeColor(suite.title) }`)
99 }
100 this.increaseIndent();
101
102 }).on(EVENT_SUITE_END, (suite) => {
103 this.flush(true);
104 this.decreaseIndent();
105 const logs = this._suiteLogs.pop();
106 if (logs.length) {
107 logs.join("\n").split("\n").forEach((line) => {
108 this.log(` <magenta+>&gt;&gt; <dim>${ escapeColor(line) }`);
109 });
110 }
111 if (suite.title.trim()) { this.log(""); }
112
113 }).on(EVENT_TEST_BEGIN, (test) => {
114 this._testLogs.push([ ]);
115 test._ethersLog = (text) => {
116 this._testLogs[this._testLogs.length - 1].push(getString(text))
117 };
118
119 }).on(EVENT_TEST_END, (test) => {
120 const logs = this._testLogs.pop();
121 if (logs.length) {
122 this.flush(false);
123 logs.join("\n").split("\n").forEach((line) => {
124 this.log(` <cyan+>&gt;&gt; <cyan->${ escapeColor(line) }`);
125 });
126 }
127
128 }).on(EVENT_TEST_PASS, (test) => {
129 this.addPass(test.title);
130
131 }).on(EVENT_TEST_FAIL, (test, error) => {
132 this.flush();
133 this._errors.push({ test, error });
134 this.log(
135 ` [ <red+>fail(${ this._errors.length }): <red>${ escapeColor(test.title) } - <normal>${ escapeColor(error.message) } ]`

Callers

nothing calls this directly

Calls 14

logMethod · 0.95
increaseIndentMethod · 0.95
flushMethod · 0.95
decreaseIndentMethod · 0.95
addPassMethod · 0.95
getTimeFunction · 0.70
getStringFunction · 0.70
escapeColorFunction · 0.70
onceMethod · 0.65
onMethod · 0.65
popMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected