UNPKG

washington.formatter.browser

Version:

Colorful browser console formatter for the Washington unit test library

51 lines (47 loc) 1.13 kB
const {green, red, yellow} = require('./colors') const formatterBrowser = require('./') const collectFourCalls = callback => { let calls = [] return (...xs) => { calls.push(xs) if (calls.length === 4) { callback(calls) } } } module.exports = [ { description: 'prints a colorful output', test: check => { const suiteResult = [ { description: 'testing', result: { type: 'success' } }, { description: 'to be ignored', result: { type: 'pending' } }, { description: 'fails', result: { type: 'failure', message: 'assertion error', stack: ['something', 'multiline'] } } ] formatterBrowser(collectFourCalls(check))(suiteResult).run() }, shouldEqual: [ ['%c testing', `color: ${green}`], ['%c to be ignored', `color: ${yellow}`], ['%c fails\nassertion error\n something\n multiline', `color: ${red}`], ['1 success • 1 pending • 1 failure'] ] } ]