Skip to content

Commit 00ba530

Browse files
committed
calc totalTime for testsuite dynamically
1 parent bd7b7f5 commit 00ba530

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

tests/run_tests.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ function displayTestSuite(tSuite) {
128128
}
129129
});
130130

131+
const totalTime = tSuite.tests.reduce((a, b) => a + b.timeTaken, 0);
131132
process.stdout.write(
132-
`\nTotal Time: ${tSuite.totalTime} ms, Avg Time: ${tSuite.totalTime /
133+
`\nTotal Time: ${totalTime} ms, Avg Time: ${totalTime /
133134
tSuite.tests
134135
.length} ms\n_______________________________________________________________________________\n`,
135136
);
@@ -152,7 +153,6 @@ fileScannerSync({
152153
const tSuite = {
153154
fileName: '',
154155
funcName: '',
155-
totalTime: 0,
156156
tests: [],
157157
};
158158

@@ -173,12 +173,10 @@ fileScannerSync({
173173
tSuite.fileName = path.basename(relativePath);
174174
tSuite.funcName = funcToBeTested.name;
175175

176-
tSuite.totalTime = 0;
177176
tests[testPath].tests.forEach((test) => {
178177
const testRes = runTest(test, funcToBeTested);
179178

180179
tSuite.tests.push({...test, ...testRes});
181-
tSuite.totalTime += testRes.timeTaken;
182180

183181
if (testRes.hasPassed) {
184182
totalTestsPassed++;

0 commit comments

Comments
 (0)