Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including coba with all npm packages installed. Try it out:

var coba = require("coba")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

coba v1.0.29

Functional Testing boilerplate

Coba

Coba is simple tool to help us to do functional system testing easier.

##Installation

To install coba using npm you just need type

npm install coba

##Usage

coba support create test case, generate data

###Initiate Test

You can initiate functional test with

coba init name

//for example

coba init registration_page

###Generate data

For now coba just generate normal data and null data for invalid data.

First you need to edit config.js file and

var config = {
  /*
    browser that you use
  */
  'browser':'firefox',
  
  /*
    Scenario Test
  */
  'scenario':'test.js',

  /*
    Input form that available on your test page 
    Ex: 
      [
        {
          'type':'string',
          'selector':'.sel',
        }
      ]
  */
  'input':[
    {
      'type':'name',
      'selector': "[name='name']",
      'name':'name',
      'validation':['required','min:8','max:20']
    },
    {
      'type':'email',
      'selector': "[name='email']",
      'name':'email',
      'validation':['required','min:8','max:20']
    },
    {
      'type':'password',
      'selector': "[name='password']",
      'name':'password',
      'validation':['required','min:8']
    }
  ],
  
  /*
    your page test url
    Ex : http://www.example.com
  */
  'url':'http://todoapps.dev/register',
  
  /*
    data location ehich store our generated data
  */
  'data':'data.json'
  
}

After that we can call coba generate syntax

  coba generate input

after that you will have generated dataon your data.json. It will be like this

 {
    "value": {
      "[name='name']": "Cyril Kub",
      "[name='email']": "Summer.Hauck72@yahoo.com",
      "[name='password']": "qm0LbBWjANepvOy"
    },
    "result": "Your account has been created and activation link already send to your email"
  },
  {
    "value": {},
    "result": [
      "The name field is required.",
      "The email field is required.",
      "The password field is required."
    ]
  },
  {
    "value": {
      "[name='name']": "Camila Russel"
    },
    "result": [
      "The email field is required.",
      "The password field is required."
    ]
  }

And offcourse we provide result of the process, the result generated base on your validation on the input. for now it's just recognize required property :D

You can modified result message by create message.js on your current test folder

var messages = {
  'success': 'Your account has been created and activation link already send to your email',
  'required: "${name} field absolutelly required"
}

module.exports = messages;

After you generated input you can run test by

coba test config.js

But remember, before you run test you need Selenium standalone server to be run, check http://seleniumhq.com for download link

PS: Please note this, this project is unfinished project.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free