Skip to content

bs123/mock-n-roll

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mock-n-roll

configurable rest service system mock

deprecated

use mountebank - over the wire test doubles http://www.mbtest.org/

Motivation

  • you don't need mock-n-roll for mocking service layers in your unit tests, use Sinion
  • you don't need mock-n-roll for mocking http requests in your integration tests, use network interceptors - nock is cool
  • when doing blackbox testing of your client side code, you may want to use mock-n-roll.

Demo

gif

curl example

before / setUp

  • you could specify any repsonse body in the post body
  • you cold specify any service call as path parameter, here environment, /mock/configure/environment/200
  • you cold specify any response http code as path parameter, here 200, /mock/configure/environment/200
echo '{
    "location": {"longitude": 89.582, "latitude": 99.1351},
    "zipId": "19900135",
    "ssd": {},
    "connection": {"wifiStatus": "OK", "radioStatus": "HIGH"}
      }
' | curl -X POST -d @- http://localhost:3081/mock/configure/environment/200 --header "Content-Type:application/json"

test / action that triggers the call

curl http://localhost:3081/api/v1/environment

after / tearDown

curl -X DELETE http://localhost:3081/mock/configure

code example

before

todo mocha before

test

after

mock-n-roll.config.js

module.exports = {
    vHost: 'your.funny.domain.dev',
    baseUrl: '/api/v1',
    port: 1234,
    mockedMethods = [
        'get',
        'post',
        'put',
        'patch',
        'delete',
        // 'head'
    ]
}

TODO

  • get rid of connect-*
  • cross-env or cli or node standard
  • author
  • lib usage
  • eslint autofix
  • SwaggerDoc
  • licence
  • mxd-eslint

upcoming features

  • default overrule pathes (feature)
  • proxy recording mode
  • ngrok

used/liked

            * express
            * https://github.com/icholy/ttygif
            * https://github.com/swagger-api/swagger-js
            * https://jbt.github.io/markdown-editor
 $ git commit -a  --author="bs <email>" -m "readme"

License

Copyright 2016

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.