Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { stdout, stderr } from 'test-console';
// $ExpectType Inspector
stdout.inspect();
// $ExpectType Inspector
stdout.inspect({isTTY: true});
// $ExpectError
stdout.inspectSync();
// $ExpectError
stdout.inspectSync({});
// $ExpectType ReadonlyArray || Output
stdout.inspectSync({isTTY: false}, (output) => output);
// $ExpectType Restore
stdout.ignore();
// $ExpectType Restore
stdout.ignore({isTTY: false});
// $ExpectError
stdout.ignoreSync();
// $ExpectType void
it('logs out using the error channel', () => {
// Catch all console logs
const inspect = stdout.inspect();
// Mocking the stderr stream
(new Stream())
.on('data', data => installer.logError(data))
.emit('data', 'Some nasty error here');
inspect.restore();
expect(inspect.output.join(' ')).to.satisfy(StringIncludesAll('ERROR', 'Some nasty error here'));
});
});
it('should print output plus newline', function () {
var stdo = stdout.inspect();
println(1, 'this', 'that');
stdo.restore();
assert.equal(stdo.output[0], '1 this that\n');
});
})
test('proxy logger instance methods', (assert) => {
const config = new Config()
config.set('app.logger', {
transport: 'console',
console: {
driver: 'console'
}
})
const logger = new LoggerFacade(config)
const inspect = stdout.inspect()
logger.info('hello')
inspect.restore()
assert.include(inspect.output[0], 'hello')
})
const spyOnConsole = () => {
_inspect = _stdout.inspect();
_inspectE = _stderr.inspect();
};
beforeEach(() => {
inspect = stdout.inspect();
delete global[globalKey];
pss.track('pub', 'bye.world', { updatedAt: Date.now() - 1000 });
pss.track('pub', 'bye.world', { updatedAt: Date.now() - 1000 });
pss.track('pub', 'bye.world', { updatedAt: Date.now() - 1000 });
pss.track('pub', 'hello.world', { updatedAt: Date.now() - 1 });
pss.track('sub', 'hello.world', { updatedAt: Date.now() - 1 });
pss.track('sub', 'bye.world', { updatedAt: Date.now() - 1 });
pss.log('MyProcessName');
});
beforeEach(function () {
this.stdout = stdout.inspect()
this.stderr = stderr.inspect()
})
function testLog(fn, ...args) {
let inspect = stdout.inspect()
let result = (fn(...args)).pop()
inspect.restore()
return result.pop()
}
beforeEach(() => {
inspect = stdout.inspect();
});
beforeEach(() => inspect = stdout.inspect());
afterEach(() => {