|
@ -1,3 +1,5 @@ |
|
|
|
|
|
const { log } = console; |
|
|
|
|
|
|
|
|
const _runTests = require('./lib/runTests'); |
|
|
const _runTests = require('./lib/runTests'); |
|
|
const _expect = require('./lib/expect'); |
|
|
const _expect = require('./lib/expect'); |
|
|
|
|
|
|
|
@ -16,21 +18,31 @@ class Gunner { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
run () { |
|
|
run (options = {}) { |
|
|
|
|
|
process.stdout.write(`Running ${this.tests.length} tests...`); |
|
|
return _runTests(this.tests) |
|
|
return _runTests(this.tests) |
|
|
.then(results => { |
|
|
.then(results => { |
|
|
|
|
|
process.stdout.clearLine(); |
|
|
|
|
|
process.stdout.cursorTo(0); |
|
|
const success = results.filter(r => r.result === 'pass'); |
|
|
const success = results.filter(r => r.result === 'pass'); |
|
|
const successPercent = Math.floor(success.length/results.length * 100); |
|
|
const successPercent = Math.floor(success.length/results.length * 100); |
|
|
|
|
|
|
|
|
console.log( |
|
|
if (('log' in options && options.log) || !('log' in options)) { |
|
|
|
|
|
log( |
|
|
`\n${success.length} tests passed of ${results.length}`, |
|
|
`\n${success.length} tests passed of ${results.length}`, |
|
|
`[${successPercent}% success]\n` |
|
|
`[${successPercent}% success]\n` |
|
|
); |
|
|
); |
|
|
results.forEach(r => { |
|
|
results.forEach(r => { |
|
|
console.log(`${r.result === 'pass' ? '✅' : '❌'} ::`, |
|
|
log(`${r.result === 'pass' ? '✅' : '❌'} ::`, |
|
|
`${r.description}`, |
|
|
`${r.description}`, |
|
|
`${r.error ? `\n Traceback:\n ${stringify(r.error)}` : ''}`); |
|
|
`${options.stack ? |
|
|
|
|
|
r.error |
|
|
|
|
|
? `\n Traceback:\n ${stringify(r.error)}` |
|
|
|
|
|
: '' |
|
|
|
|
|
: ''}`);
|
|
|
}); |
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return results; |
|
|
return results; |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|