Skip to content

cellsjs/pisco-test-framework-tests

Repository files navigation

Pisco Unit Tests - Test recipe.

Writing a test for piscosour. First require stepTester

 const tester = require('piscosour/lib/tests/stepTester');
  1. command object
  2. setLoggerLevel(level) method
  3. loadStep(command) method
  4. runStep(command) method

command object.

Param Type Optional Description
name String No The name of the step
context Array Yes Array of the contexts runned
baseDir String Yes Folder where the step is going to be runned. Default is the root of the recipe.
params Object Yes All params passed for the execution

Is the configuration parameter that piscosour use to run the test.

setLoggerLevel(level) method

logger.setLoggerLevel(level) set logger level for piscosour. See logger for more information

Param Type Optional Description
level Number No 0...5 log levels

loadStep(command) method

logger.loadStep(command) Load local step with all plugins and all piscosour configuration. Returns step object with all piscosour features loaded.

Param Type Optional Description
command Object No See command object

runStep(command) method

logger.runStep(command) Run one local step from the recipe. Returns a promise with the execution of the step.

Param Type Optional Description
command Object No See command object

This is a example of a entire test file.

'use strict';

const path = require('path');
const tester = require('piscosour/lib/tests/stepTester');
const expect = require('chai').expect;
const assert = require('assert');

/* global define, it, describe, before, beforeEach, afterEach, after */

// configure

tester.setLoggerLevel(0);

// constants

const stepName = 'askHello';
const contexts = ['world'];
const message = 'Unit Framework hola!';

describe('Unit testing framework for askHello step', () => {
  it('Should return the step to test', (done) => {
    const step = tester.loadStep({
      name: stepName,
      context: contexts
    });
    expect(step).not.equal(null);
    expect(step.name).to.equal(stepName);
    done();
  });
  it('Should run the step to test', (done) => {
    tester.setLoggerLevel(0);
    tester.runStep({
        name: stepName,
        context: contexts,
        baseDir: path.join(__dirname, 'world'),
        params: {
          paramInquire: message
        }
      })
      .then(() => {
        done();
      })
      .catch((err) => {
        done(err);
      })
  });
  it('Should run the step with plugins to test', (done) => {
    tester.setLoggerLevel(0);
    tester.runStep({
        name: 'emittingHello',
        context: contexts,
        baseDir: path.join(__dirname, 'world'),
        params: {
          paramInquire: message
        }
      })
      .then(() => {
        done();
      })
      .catch((err) => {
        done(err);
      })
  });
});

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published