Skip to content

Commit

Permalink
Report about progress via console log
Browse files Browse the repository at this point in the history
Ref: #5
  • Loading branch information
projkov committed Sep 9, 2024
1 parent 8ec788b commit 8a14386
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
18 changes: 8 additions & 10 deletions src/custom-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@ class CustomReporter {
constructor(globalConfig, options) {
this._globalConfig = globalConfig;
this._options = options;
this.totalTests = 0;
this.testCount = 0;
this.totalSuites = 0;
this.suitesCount = 0;
}

onRunStart(test, testSuiteResults) {
testSuiteResults.testResults.forEach((suite) => {
this.totalTests += suite.numPassingTests + suite.numFailingTests + suite.numPendingTests;
});
console.log(`Total tests found: ${this.totalTests}`);
onRunStart(test) {
this.totalSuites = test.numTotalTestSuites;
console.log('Total test suites:', this.totalSuites);
}

onTestResult(test, testResult, aggregatedResult) {
this.testCount += testResult.numPassingTests + testResult.numFailingTests + testResult.numPendingTests;
console.log(`Progress: ${this.testCount}/${this.totalTests}`);
onTestResult() {
this.suitesCount += 1;
console.log(`Progress: ${this.suitesCount}/${this.totalSuites}`);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/modules/test_runs/testRun.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ export class TestRunController {
globals: JSON.stringify({
SESSION_ID: sessionId,
}),
reporters: ['default', '<rootDir>/src/custom-reporter.js'],
// reporters: ['default', 'jest-progress-bar-reporter'],
reporters: ['default', ['<rootDir>/src/custom-reporter.js', { SESSION_ID: sessionId }]],
},
...optionsWithTest,
};
Expand Down

0 comments on commit 8a14386

Please sign in to comment.