Skip to content

Commit

Permalink
adding notes before making change
Browse files Browse the repository at this point in the history
unecessary dif

temp

add logs for pending tests

fix linting issues

undo unecessary change
  • Loading branch information
kevo1ution committed Oct 25, 2022
1 parent 7007f13 commit ce2b12e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/reporters/default.js
Expand Up @@ -370,8 +370,11 @@ export default class Reporter {
}

this.lineWriter.writeLine(`${testsInFile.size} tests were pending in ${this.relativeFile(file)}\n`);
const testTitleToLogs = evt.pendingTestsLogReference.get(file) ?? new Map();
for (const title of testsInFile) {
const logs = testTitleToLogs.get(title) ?? [];
this.lineWriter.writeLine(`${figures.circleDotted} ${this.prefixTitle(file, title)}`);
this.writeLogs({logs});
}

this.lineWriter.writeLine('');
Expand Down
17 changes: 17 additions & 0 deletions lib/run-status.js
Expand Up @@ -9,6 +9,7 @@ export default class RunStatus extends Emittery {
super();

this.pendingTests = new Map();
this.pendingTestsLogReference = new Map();

this.emptyParallelRun = parallelRuns
&& parallelRuns.currentFileCount === 0
Expand Down Expand Up @@ -60,6 +61,7 @@ export default class RunStatus extends Emittery {
});

this.pendingTests.set(testFile, new Set());
this.pendingTestsLogReference.set(testFile, new Map());
worker.onStateChange(data => this.emitStateChange(data));
}

Expand Down Expand Up @@ -124,22 +126,31 @@ export default class RunStatus extends Emittery {
fileStats.remainingTests--;
this.removePendingTest(event);
break;
case 'test-register-log-reference':
this.addLogReference(event);
break;
case 'timeout':
stats.timeouts++;
event.pendingTests = this.pendingTests;
event.pendingTestsLogReference = this.pendingTestsLogReference;
this.pendingTests = new Map();
this.pendingTestsLogReference = new Map();
for (const testsInFile of event.pendingTests.values()) {
stats.timedOutTests += testsInFile.size;
}

break;
case 'interrupt':
event.pendingTests = this.pendingTests;
event.pendingTestsLogReference = this.pendingTestsLogReference;
this.pendingTests = new Map();
this.pendingTestsLogReference = new Map();
break;
case 'process-exit':
event.pendingTests = this.pendingTests;
event.pendingTestsLogReference = this.pendingTestsLogReference;
this.pendingTests = new Map();
this.pendingTestsLogReference = new Map();
break;
case 'uncaught-exception':
stats.uncaughtExceptions++;
Expand Down Expand Up @@ -198,6 +209,12 @@ export default class RunStatus extends Emittery {
return 0;
}

addLogReference(event) {
if (this.pendingTestsLogReference.has(event.testFile)) {
this.pendingTestsLogReference.get(event.testFile).set(event.title, event.logs);
}
}

addPendingTest(event) {
if (this.pendingTests.has(event.testFile)) {
this.pendingTests.get(event.testFile).add(event.title);
Expand Down
6 changes: 6 additions & 0 deletions lib/runner.js
Expand Up @@ -358,6 +358,12 @@ export default class Runner extends Emittery {
notifyTimeoutUpdate: this.notifyTimeoutUpdate,
});

this.emit('stateChange', {
type: 'test-register-log-reference',
title: task.title,
logs: test.logs,
});

const result = await this.runSingle(test);
testOk = result.passed;

Expand Down

0 comments on commit ce2b12e

Please sign in to comment.