Created
November 30, 2018 04:30
-
-
Save patrixr/715ef077dcc108a9c06358f1df53418d to your computer and use it in GitHub Desktop.
Minimal EmberJS testing output for CI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const chalk = require('chalk'); | |
const cli = require('ember-cli'); | |
const fs = require('fs'); | |
let enableLog = false; | |
let failures = 0; | |
function wrapStream(stream) { | |
const _write = stream.write.bind(stream); | |
const _print = (txt) => _write(txt + "\n"); | |
stream.write = (input) => { | |
const lines = input.toString().split('\n'); | |
lines.forEach((l) => { | |
if (/^ok /.test(l)) { | |
// Print successful tests in blue | |
_print(chalk.magenta(l)); | |
enableLog = false; | |
return; | |
} | |
if (/^not ok /.test(l)) { | |
l = chalk.red(l); | |
enableLog = true; | |
failures++; | |
} | |
if (enableLog && /Log: /.test(l)) { | |
// Logs are too verbose, remove them | |
_print(l.replace(/Log: .*$/, '')); | |
enableLog = false; | |
} | |
if (enableLog) { | |
_print(l); | |
} | |
}); | |
}; | |
return _print; | |
} | |
const log = wrapStream(process.stdout); | |
const err = wrapStream(process.stderr); | |
log(chalk.cyan('Ember tests are running...')); | |
cli({ | |
inputStream: process.stdin, | |
outputStream: process.stdout, | |
errorStream: process.stderr, | |
cliArgs: ['test'] | |
}).then(() => { | |
log(chalk.yellow('-----')); | |
log(chalk.yellow('----- RESULTS:')); | |
log(chalk.yellow(`----- Testing completed with ${failures} Failures`)); | |
log(chalk.yellow('-----')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment