How to use the test-console.stdout function in test-console

To help you get started, we’ve selected a few test-console examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github duyluonglc / lucid-mongo / test / acceptance / commands.spec.js View on Github external
/*
|--------------------------------------------------------------------------
| COMMANDS
|--------------------------------------------------------------------------
|
| Ace commands tests are written in this file.
|
*/

/* global describe, it, after, before */
const chai = require('chai')
const expect = chai.expect
const fold = require('adonis-fold')
const Ioc = fold.Ioc
const stdout = require('test-console').stdout
const setup = require('./setup')
require('co-mocha')

describe('Commands', function () {
  before(function * () {
    yield setup.loadProviders()
    setup.registerCommands()
    const LucidMongo = Ioc.use('Adonis/Src/LucidMongo')
    class User extends LucidMongo {}
    Ioc.bind('App/Model/User', function () {
      return User
    })

    this.database = Ioc.use('Adonis/Src/Database')
  })
github leonardoanalista / corp-semantic-release / spec / validateBranch.spec.js View on Github external
'use strict';
const expect = require('chai').expect;
const rewire = require('rewire');
const stdout = require('test-console').stdout;
const validateBranch = rewire('../src/lib/validateBranch'); // NOTE: rewired!

describe('validateBranch', () => {
  let revert = () => {};

  afterEach(() => revert()); // revert the mocking of anything

  it('should show a message if the current branch is not the release branch and exit with 0', () => {
    let exitCode;
    revert = validateBranch.__set__({
      shell: {
        exec: () => ({stdout: 'fooBranch\n'}),
        exit: (code) => {
          exitCode = code;
          return;
        },
github kartikayg / StatusPage / logger-service / src / app.spec.js View on Github external
it ('should not log request log message if not an object', function (done) {

      const inspect = testConsole.stdout.inspect();

      const message = 'hello kartikay';
      exchange.publish('request', JSON.stringify(message));

      // wait for a second
      setTimeout(() => {

        inspect.restore();

        // check for console
        assert.strictEqual(inspect.output.length, 0);

        done();

      }, 1000);
github sandcastle / mocha-circleci-reporter / test / index.js View on Github external
it('should output junit file', function() {

        new Reporter(runner, {
          reporterOptions: { mochaFile: file }
        });

        var stdout = testConsole.stdout.inspect();
        try{
          executeTestRunner();

          assert(fs.existsSync(file));
        }
        finally{
          stdout.restore();
        }
    });
github sandcastle / mocha-circleci-reporter / test / index.js View on Github external
it('should output spec to stdout', function() {

        new Reporter(runner, {
          reporterOptions: { mochaFile: file }
        });

        var stdout = testConsole.stdout.inspect();
        try{
          executeTestRunner();
        }
        finally{
          stdout.restore();
        }

        assert(stdout.output[1], '\u001b[0mFoo Bar module\u001b[0m\n');
    });
github jonathaneunice / iterm2-tab-set / test / test_util.js View on Github external
const assert = require('chai').assert
const _      = require('underscore')
const path   = require('path')
const process = require('process')
const fs     = require('fs');
const stdout = require("test-console").stdout;
const stderr = require("test-console").stderr;
const util = require('../util');
util.globalize(util);

describe('util', function() {

  describe('globalize', function(){
    it('should make functions globally available', function(){
      assert.isFunction(definedOr);
      assert.isFunction(padRight);
      assert.isFunction(maxLength);
      assert.isFunction(longest);
    })
  })

  describe('definedOr', function () {
github skleeschulte / babel-plugin-transform-semantic-ui-react-imports / test / index.js View on Github external
var fs = require('fs');
var path = require('path');
var babel6 = require('babel-core');
var babel7 = require('@babel/core');
var stdout = require('test-console').stdout;
var assert = require('assert');

function alignLines(string) {
    return string.split(/\n/)
        .map(function(line) { return line.trim(); })
        .filter(function(line) { return line !== ''; })
        .join('\n');
}

describe('babel-plugin-transform-semantic-ui-react-imports', function() {
    var fixtures = fs.readdirSync(path.resolve(__dirname, 'fixtures'));

    var babelVersions = [
        { name: "Babel 6", transformFileSync: babel6.transformFileSync, transformSync: babel6.transform },
        { name: "Babel 7", transformFileSync: babel7.transformFileSync, transformSync: babel7.transformSync }
        ];
github brunch / brunch / test / _test_helper.js View on Github external
try {
    t.is(fs.readFileSync(path, 'utf8'), content);
  } catch (e) {
    t.fail(e.message);
  }
};

const fileDoesNotContain = (t, path, content) => {
  try {
    t.false(fs.readFileSync(path, 'utf8').includes(content));
  } catch (e) {
    t.fail(e.message);
  }
};

const _stdout = require('test-console').stdout;
const _stderr = require('test-console').stderr;
let _inspect, _inspectE;

const spyOnConsole = () => {
  _inspect = _stdout.inspect();
  _inspectE = _stderr.inspect();
};

const restoreConsole = () => {
  _inspect.restore();
  _inspect.output.forEach(line => process.stdout.write(line));
  _inspect = null;

  _inspectE.restore();
  _inspectE.output.forEach(line => process.stderr.write(line));
  _inspectE = null;
github adonisjs / adonis-framework / test / unit / logger.spec.js View on Github external
'use strict'

/*
 * adonis-framework
 *
 * (c) Harminder Virk 
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
*/

const test = require('japa')
const path = require('path')
const fs = require('fs-extra')
const { ioc } = require('@adonisjs/fold')
const stdout = require('test-console').stdout
const { Config, Helpers } = require('@adonisjs/sink')

const FileDriver = require('../../src/Logger/Drivers').file
const ConsoleDriver = require('../../src/Logger/Drivers').console
const Logger = require('../../src/Logger')
const LoggerManager = require('../../src/Logger/Manager')
const LoggerFacade = require('../../src/Logger/Facade')

const sysLog = {
  emerg: 0,
  alert: 1,
  crit: 2,
  error: 3,
  warning: 4,
  notice: 5,
  info: 6,