Skip to content

Commit

Permalink
WIP: Add basic custom reporter
Browse files Browse the repository at this point in the history
Ref: #5
  • Loading branch information
projkov committed Sep 9, 2024
1 parent 8dcd50f commit 8ec788b
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"flatted": "^3.3.1",
"http-proxy": "^1.18.1",
"http-proxy-middleware": "^3.0.0",
"jest-progress-bar-reporter": "^1.0.25",
"pg": "^8.12.0",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
Expand Down
22 changes: 22 additions & 0 deletions src/custom-reporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class CustomReporter {
constructor(globalConfig, options) {
this._globalConfig = globalConfig;
this._options = options;
this.totalTests = 0;
this.testCount = 0;
}

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

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

module.exports = CustomReporter;
2 changes: 2 additions & 0 deletions src/modules/test_runs/testRun.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export class TestRunController {
globals: JSON.stringify({
SESSION_ID: sessionId,
}),
reporters: ['default', '<rootDir>/src/custom-reporter.js'],
// reporters: ['default', 'jest-progress-bar-reporter'],
},
...optionsWithTest,
};
Expand Down
27 changes: 27 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,14 @@ caniuse-lite@^1.0.30001646:
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001649.tgz#3ec700309ca0da2b0d3d5fb03c411b191761c992"
integrity sha512-fJegqZZ0ZX8HOWr6rcafGr72+xcgJKI9oWfDW5DrD7ExUtgZC7a7R7ZYmZqplh7XDocFdGeIFn7roAxhOeYrPQ==

[email protected]:
version "4.1.1"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.1.tgz#c80b3fab28bf6371e6863325eee67e618b77e6ad"
integrity sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

[email protected], chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
Expand Down Expand Up @@ -3312,6 +3320,15 @@ jest-pnp-resolver@^1.2.2:
resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz#930b1546164d4ad5937d5540e711d4d38d4cad2e"
integrity sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==

jest-progress-bar-reporter@^1.0.25:
version "1.0.25"
resolved "https://registry.yarnpkg.com/jest-progress-bar-reporter/-/jest-progress-bar-reporter-1.0.25.tgz#c292431023bd86947ead8cceba9e8f665f21a092"
integrity sha512-iFWtsl0j+OeHeMCu5fXL8pSN3h06NQlG/UPpcuO2PP2C+hr81K397+Mh34rU3GgA9kQga6ctu7gfOEOgUlKFug==
dependencies:
chalk "4.1.1"
moment "^2.29.4"
progress "2.0.3"

jest-regex-util@^29.6.3:
version "29.6.3"
resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-29.6.3.tgz#4a556d9c776af68e1c5f48194f4d0327d24e8a52"
Expand Down Expand Up @@ -3782,6 +3799,11 @@ mkdirp@^2.1.3:
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-2.1.6.tgz#964fbcb12b2d8c5d6fbc62a963ac95a273e2cc19"
integrity sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A==

moment@^2.29.4:
version "2.30.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae"
integrity sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
Expand Down Expand Up @@ -4209,6 +4231,11 @@ process-nextick-args@~2.0.0:
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==

[email protected]:
version "2.0.3"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"
integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==

prompts@^2.0.1:
version "2.4.2"
resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.2.tgz#7b57e73b3a48029ad10ebd44f74b01722a4cb069"
Expand Down

0 comments on commit 8ec788b

Please sign in to comment.