GithubHelp home page GithubHelp logo

frappe's Introduction

Machiatto

Behaviour driven test framework.

Motivation

Machiatto is Mocha inspired frawemork. There was several motivation points, why I think it's time to reconsider Mocha.

  1. Mocha supposed to be BDD framework. Each time I try to explain BDD priciples with Mocha, it appears to be hard because of inspite of common BDD language of "given-when-then", it exposes API based on "describe-before-it" methods, that makes inpedence mismatch between BDD language and framework itself.

  2. In Mocha nested context are nested describe functions. With too many nested contexts, the code blocks move right and it's a harder to read such code and maintantain it. Besides, the code re-use between specs are impossible, some many times you put it to some utitlity objects and call from specs.

  3. Mocha exposes all their API as global functions, so describe or it are usually warnings for jshint.

Machiatto is an effort to fix Mocha and provide better BDD testing framework.

Usage

Install machiatto as npm package,

> npm install machiatto --save

Create helloworld.spec.js file,

var behavior = require('machiatto');
var expect = require('expect.js');

var spec = behaviour('hello world specs');

spec('hello world behaviour')
	.when('world is created', function (context) {
		context.world = new World();
	})

	.and('greet', function (context) {
		context.result = context.world.greet();
	})

	.should('respond hello', function (context) {
		expect(context.result).to.equal('hello');
	});

module.exports = spec;

Then in byeworld.spec.js file,

var behavior = require('machiatto');
var expect = require('expect.js');

var spec = behaviour('hello');

spec('bye world behaviour')
	.when('world is created')

	.and('bye', function (context) {
		context.result = context.world.bye();
	})

	.should('respond bye', function (contexts) {
		expect(context.result).to.equal('bye-bye');
	});

module.exports = spec;

See /test.

Features

  • Context re-use between tests and files
  • Better structure for same context tests
  • Sync and async code testing
  • Browser and node.js
  • Simple to use

API

TBD.

License

MIT (c) [email protected]

frappe's People

Contributors

alexbeletsky avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.