node-mockit

mock http api use nodejs

Downloads
10
Stars
13

#nodejsmock Http

mock.jscli.js

API

  1. nodejs

  2. node-mockit

    sudo npm install https://github.com/ipconfiger/node-mockit.git -g

    sudo npm install node-mockit -g

  3. mkdir ./scripts

  4. cli -e > ./scripts/test.js

  5. mock -s ./scripts mock

cli -s -h cli -s ./scripts -b http://127.0.0.1:25300

exports.config={
    name:"test7",   // 
    url:"/test",    //
    request:{       //
        method:"POST",  //
        headers:{Authorization:"Basic token"}, //header
        type:"body",  //body,form,get 
        data:{        //
            name:"alex",
            password:"XXXX",
        }
    },
    response:{       //
        content_type:"application/json",     //
        success:{                            //
            rs:true,
            info:""
        },
        error:{                              //
            rs:false,
            error:"error info"
        }
    }
}

###body

postjsonbody

###form

form

###get

GETquerystring

mock -h

Usage: mock [options]

Options:

  -h, --help           
  -V, --version        
  -s,--scripts [type]  ./scripts
  -p,--port [type]      25300
  -l,--level [type]    0= 1= 2= 1

cli --help

Usage: cli [options]

Options:

  -h, --help          
  -V, --version       
  -e,--example        example
  -s,--script [type]  ./scripts
  -b,--host [type]     [http://127.0.0.1:25300]