From eb0bea722d249a79e93d0600971e6ab480b4ed6e Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 13 Dec 2021 17:21:43 +0530 Subject: [PATCH] tests summary --- .../src/lib/solidity-unit-testing.tsx | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx index f8c2f2a4d3..1b3dc4d804 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx +++ b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx @@ -62,6 +62,7 @@ export const SolidityUnitTesting = (props: any) => { let testSuite: any let testSuites: any let runningTestFileName: any + let runningTests: any @@ -252,7 +253,7 @@ export const SolidityUnitTesting = (props: any) => { } } - const showTestsResult = (runningTests: any) => { + const showTestsResult = () => { console.log('runningTests---->', runningTests) setTestsOutput([]) let filenames = Object.keys(testsResultByFilename) @@ -289,7 +290,7 @@ export const SolidityUnitTesting = (props: any) => { for(const test of tests) { console.log('test---->', test) if (test.type === 'testPass') { - if (test.hhLogs && test.hhLogs.length) printHHLogs(test.hhLogs, test.value) + // if (test.hhLogs && test.hhLogs.length) printHHLogs(test.hhLogs, test.value) const testPassCard: any = (
{ } } else { // show only contract and file name - const ContractCard: any = ( + const contractCard: any = (
{contract} ({filename})
) - setTestsOutput(prevCards => ([...prevCards, ContractCard])) + setTestsOutput(prevCards => ([...prevCards, contractCard])) } } } - // show testsSummary + // show summary + const testSummary = fileTestsResult['summary'] + if (testSummary && testSummary.filename) { + const summaryCard: any = (
+ Result for {testSummary.filename} + Passed: {testSummary.passed} + Failed: {testSummary.failed} + Time Taken: {testSummary.timeTaken}s +
) + setTestsOutput(prevCards => ([...prevCards, summaryCard])) + } } // let debugBtn // if ((result.type === 'testPass' || result.type === 'testFailure') && result.debugTxHash) { @@ -378,6 +389,7 @@ export const SolidityUnitTesting = (props: any) => { const testCallback = (result: any, runningTests: any) => { console.log('result--------------in testCallback->', result) console.log('testsResultByFilename--------============------in testCallback->', testsResultByFilename) + runningTests = runningTests if(result.filename) { if(!testsResultByFilename[result.filename]) { testsResultByFilename[result.filename] = {} @@ -387,7 +399,7 @@ export const SolidityUnitTesting = (props: any) => { testsResultByFilename[result.filename][result.value] = [] } else testsResultByFilename[result.filename][result.context].push(result) - showTestsResult(runningTests) + showTestsResult() } } @@ -422,6 +434,7 @@ export const SolidityUnitTesting = (props: any) => { const totalTime = parseFloat(result.totalTime).toFixed(2) testsSummary = { filename, passed: result.totalPassing, failed: result.totalFailing, timeTaken: totalTime } testsResultByFilename[filename]['summary']= testsSummary + showTestsResult() // setTestsSummary(testsSummary) } // fix for displaying right label for multiple tests (testsuites) in a single file