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 1c71951f42..5ece8f8686 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 @@ -16,6 +16,23 @@ interface TestObject { checked: boolean } +export interface TestResultInterface { + type: string + value: any + time?: number + context?: string + errMsg?: string + filename: string + assertMethod?: string + returned?: string | number + expected?: string | number + location?: string + hhLogs?: [] + web3?: any + debugTxHash?: string + rendered?: boolean +} + export const SolidityUnitTesting = (props: Record) => { const { helper, testTab, initialPath } = props @@ -139,8 +156,7 @@ export const SolidityUnitTesting = (props: Record) => { }, []) // eslint-disable-line const updateDirList = (path: string) => { - testTabLogic.dirList(path).then((options: any) => { - console.log('options in testDir List--->', options) + testTabLogic.dirList(path).then((options: string[]) => { setPathOptions(options) }) } @@ -213,7 +229,7 @@ export const SolidityUnitTesting = (props: Record) => { setPathOptions(pathOptions) } - const cleanFileName = (fileName: any, testSuite: any) => { + const cleanFileName = (fileName: string, testSuite: string) => { return fileName ? fileName.replace(/\//g, '_').replace(/\./g, '_') + testSuite : fileName } @@ -224,9 +240,8 @@ export const SolidityUnitTesting = (props: Record) => { testTab.call('debugger', 'debug', txHash, web3) } - const printHHLogs = (logsArr: any, testName: any) => { + const printHHLogs = (logsArr: Record[], testName: string) => { let finalLogs = `${testName}:\n` - console.log('logsArr======>', logsArr) for (const log of logsArr) { let formattedLog // Hardhat implements the same formatting options that can be found in Node.js' console.log, @@ -307,8 +322,8 @@ export const SolidityUnitTesting = (props: Record) => { }) } - const renderTests = (tests: any, contract: any, filename: any) => { - const index = tests.findIndex((test: any) => test.type === 'testFailure') + const renderTests = (tests: TestResultInterface[], contract: string, filename: string) => { + const index = tests.findIndex((test: TestResultInterface) => test.type === 'testFailure') // show filename and contract renderContract(filename, contract, index) // show tests @@ -346,7 +361,7 @@ export const SolidityUnitTesting = (props: Record) => { const testFailCard1: any = (
highlightLocation(test.location, test.filename)} + onClick={() => { if(test.location) highlightLocation(test.location, test.filename)}} >
✘ {test.value} @@ -363,7 +378,7 @@ export const SolidityUnitTesting = (props: Record) => { const testFailCard2: any = (
highlightLocation(test.location, test.filename)} + onClick={() => { if(test.location) highlightLocation(test.location, test.filename)}} >
✘ {test.value} @@ -400,7 +415,7 @@ export const SolidityUnitTesting = (props: Record) => { for (const contract of contracts) { if (contract && contract !== 'summary' && contract !== 'errors') { runningTestFileName = cleanFileName(filename, contract) - const tests = fileTestsResult[contract] + const tests = fileTestsResult[contract] as TestResultInterface[] if (tests?.length) { renderTests(tests, contract, filename) } else { @@ -441,7 +456,7 @@ export const SolidityUnitTesting = (props: Record) => { } } - const testCallback = (result: any) => { + const testCallback = (result: Record) => { if (result.filename) { if (!testsResultByFilename[result.filename]) { testsResultByFilename[result.filename] = {}