GithubHelp home page GithubHelp logo

techquery / test-example Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 2.0 43 KB

A JSDoc plugin for generating test files by parsing @example

Home Page: https://tech-query.me/test-example/

License: MIT License

JavaScript 100.00%
jsdoc plugin automation testing npm

test-example's Introduction

Test Example

A JSDoc plugin for generating test files by parsing @example.

NPM Dependency

NPM

Sponsor

Feature

  1. BDD (Behavior-driven development) style Test wrapper, such as Mocha

  2. Should style Assertion

  3. One Source file to one Test file

  4. One Doclet to one describe()

  5. One @example to one it()

  6. // also supports multiple-line code with the example result

Usage

  1. npm i test-example -D

  2. Add some config options

  3. Custom hook module let you do more

  4. jsdoc -c path/to/config.json

  5. npm test

Example

source/say-sth.js

/**
 * Hello function
 *
 * @function hello
 *
 * @param {string} [name="World"]
 *
 * @return {string}
 *
 * @example  // No parameter
 *
 *     hello()    //  "Hello, World !"
 *
 * @example  // One parameter
 *
 *     hello('JSDoc')    //  "Hello, JSDoc !"
 */

exports.hello = function (name) {

    return  'Hello, ' + (name || 'World') + ' !';
};

will generate test/say-sth.js

'use strict';

require('should');

var saySth = require('../source/say-sth');


describe('hello',  function () {


    it('No parameter',  function () {

        var result = saySth.hello();

        result.should.be.deepEqual( "Hello, World !" );
    });


    it('One parameter',  function () {

        var result = saySth.hello('JSDoc');

        result.should.be.deepEqual( "Hello, JSDoc !" );
    });

});

[ Remark ] A blank line is necessary between the title & code of @example.

User Case

  1. iQuery.js

test-example's People

Contributors

techquery avatar

Stargazers

Tom Byrer avatar Akagilnc avatar  avatar

Watchers

James Cloos avatar Akagilnc avatar  avatar

Forkers

akagilnc itsjw

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.