update tests output

pull/2716/head^2
Aniket-Engg 2 years ago committed by Aniket
parent 24b7a55841
commit c290556193
  1. 2
      libs/remix-tests/src/run.ts
  2. 38
      libs/remix-tests/src/runTestFiles.ts
  3. 16
      libs/remix-tests/tests/testRunner.cli.spec.ts

@ -68,7 +68,7 @@ commander
}
// Console message
console.log(colors.white('\n\t👁\t:: Running tests using remix-tests ::\t👁\n'))
console.log(colors.bold('\n\t👁\t:: Running tests using remix-tests ::\t👁\n'))
// Set logger verbosity
if (commander.verbose) {

@ -43,7 +43,7 @@ export function runTestFiles (filepath: string, isDirectory: boolean, web3: Web3
name: {
badge: '\n\t◼',
label: '',
color: 'white'
color: 'whiteBright'
},
log: {
badge: '\t',
@ -118,19 +118,24 @@ export function runTestFiles (filepath: string, isDirectory: boolean, web3: Web3
let totalPassing = 0
let totalFailing = 0
let totalTime = 0
const errors: any[] = []
const _testCallback = function (err: Error | null | undefined, result: TestResultInterface) {
if (err) throw err
if (result.type === 'contract') {
signale.name(result.value.white)
signale.name(result.value)
console.log('\n')
} else if (result.type === 'testPass') {
if (result?.hhLogs?.length) result.hhLogs.forEach(printLog)
signale.result(result.value.green)
signale.result(result.value.white)
} else if (result.type === 'testFailure') {
if (result?.hhLogs?.length) result.hhLogs.forEach(printLog)
signale.error(result.value.red)
errors.push(result)
signale.error(result.value.white)
if (result.assertMethod) {
console.log(colors.green('\t Expected value should be ' + result.assertMethod + ' to: ' + result.expected))
console.log(colors.red('\t Received: ' + result.returned))
}
console.log(colors.red('\t Message: ' + result.errMsg))
console.log('\n')
}
}
const _resultsCallback = (_err: Error | null | undefined, result: ResultsInterface, cb) => {
@ -157,23 +162,16 @@ export function runTestFiles (filepath: string, isDirectory: boolean, web3: Web3
if (err) {
return next(err)
}
console.log('\n')
if (totalPassing > 0) {
console.log(colors.green(totalPassing + ' passing ') + colors.grey('(' + totalTime + 's)'))
console.log(colors.bold.underline('Tests Summary: '))
if (totalPassing >= 0) {
console.log(colors.green('Passed: ' + totalPassing))
}
if (totalFailing > 0) {
console.log(colors.red(totalFailing + ' failing'))
if (totalFailing >= 0) {
console.log(colors.red('Failed: ' + totalFailing))
}
console.log('')
errors.forEach((error, index) => {
console.log(' ' + (index + 1) + ') ' + colors.bold(error.context + ': ') + error.value)
console.log('')
console.log(colors.red('\t error: ' + error.errMsg))
console.log(colors.green('\t expected value to be ' + error.assertMethod + ' to: ' + error.expected))
console.log(colors.red('\t returned: ' + error.returned))
})
console.log(colors.white('Time Taken: ' + totalTime + 's'))
console.log('')
next()

@ -53,9 +53,9 @@ Commands:
expect(res.stdout.toString().trim()).toMatch(/AssertOkTest okFailTest/) // check if console.log is printed
expect(res.stdout.toString().trim()).toMatch(/Ok fail test/)
// match fail test details
expect(res.stdout.toString().trim()).toMatch(/error: okFailTest fails/)
expect(res.stdout.toString().trim()).toMatch(/expected value to be ok to: true/)
expect(res.stdout.toString().trim()).toMatch(/returned: false/)
expect(res.stdout.toString().trim()).toMatch(/Expected value should be ok to: true/)
expect(res.stdout.toString().trim()).toMatch(/Received: false/)
expect(res.stdout.toString().trim()).toMatch(/Message: okFailTest fails/)
})
test('remix-tests running a test file with custom compiler version', () => {
@ -69,7 +69,7 @@ Commands:
expect(res.stdout.toString().trim()).toMatch(/Ok pass test/)
expect(res.stdout.toString().trim()).toMatch(/Ok fail test/)
// match fail test details
expect(res.stdout.toString().trim()).toMatch(/error: okFailTest fails/)
expect(res.stdout.toString().trim()).toMatch(/Message: okFailTest fails/)
})
test('remix-tests running a test file with unavailable custom compiler version (should fail)', () => {
@ -88,7 +88,7 @@ Commands:
expect(res.stdout.toString().trim()).toMatch(/Ok pass test/)
expect(res.stdout.toString().trim()).toMatch(/Ok fail test/)
// match fail test details
expect(res.stdout.toString().trim()).toMatch(/error: okFailTest fails/)
expect(res.stdout.toString().trim()).toMatch(/Message: okFailTest fails/)
})
test('remix-tests running a test file by enabling optimization', () => {
@ -101,7 +101,7 @@ Commands:
expect(res.stdout.toString().trim()).toMatch(/Ok pass test/)
expect(res.stdout.toString().trim()).toMatch(/Ok fail test/)
// match fail test details
expect(res.stdout.toString().trim()).toMatch(/error: okFailTest fails/)
expect(res.stdout.toString().trim()).toMatch(/Message: okFailTest fails/)
})
test('remix-tests running a test file by enabling optimization and setting runs', () => {
@ -115,7 +115,7 @@ Commands:
expect(res.stdout.toString().trim()).toMatch(/Ok pass test/)
expect(res.stdout.toString().trim()).toMatch(/Ok fail test/)
// match fail test details
expect(res.stdout.toString().trim()).toMatch(/error: okFailTest fails/)
expect(res.stdout.toString().trim()).toMatch(/Message: okFailTest fails/)
})
test('remix-tests running a test file without enabling optimization and setting runs (should fail)', () => {
@ -138,7 +138,7 @@ Commands:
expect(res.stdout.toString().trim()).toMatch(/Ok pass test/)
expect(res.stdout.toString().trim()).toMatch(/Ok fail test/)
// match fail test details
expect(res.stdout.toString().trim()).toMatch(/error: okFailTest fails/)
expect(res.stdout.toString().trim()).toMatch(/Message: okFailTest fails/)
})
})
})
Loading…
Cancel
Save