This repository has been archived by the owner. It is now read-only.
A Hapi-Glue-Lab-Code tool that could only be created by a crazy scientist
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Join the chat at Build Status Dependency Status

A Hapi-Glue-Lab-Code tool that could only be created by a crazy scientist.

$ npm install tournesol


This package aims at making api tests using Hapi, Lab and Code easier. The idea is to focus on what the tests mean rather than how to perform them.


const Lcrud = require( 'tournesol' ).Lcrud;

var request = new Lcrud(baseURL, getPayload, getHeaders);
const Tournesol = require( 'tournesol' );
const Lcrud = require( 'tournesol' ).Lcrud;
const Lab = require( 'lab' );
const lab = exports.lab = Lab.script();

const Server = require( 'A Hapi server' ); // require the hapi server to test or build it within the test file. 

const definition = {
        title: 'Title of the test with value of {pre.half1} + {input.itemId}',
        pre: [
                assign: 'half1',
                name: 'half1 ( = 5)',
                method: function ( reply ) {

                    // no err
                    reply( null, 5 );
        paramSets: [
                titleComplement: 'hello mommy',
                input: {
                    itemId: 5
                output: {
                    statusCode: 200
                input: {
                    itemId: 10
                output: {
                    statusCode: 404
        inject: function ( pre, input ) {

            const request = new Lcrud( '/items', null, null );
            return request.get( null, null, input.itemId + pre.half1 );

    Tournesol.runTests(definition, Server, lab);


Please refer to:

  • Lcrud: List + CRUD, to generates requests for tests.
  • runTests: to run tests from a nice definition object.

About the name

Tournesol is the french name of the crazy professor in The Adventures of Tintin. You may know him by the name of Professor Calculus. This name was chosen since this package turns Lab into the home of a mad scientist.