Giter Club home page Giter Club logo

ncdc's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ncdc's Issues

Better test logging

It spits out way too much information sometimes. It'd be really cool to cut it down to the barebones. Just enough to help troubleshoot what's going wrong.

Types for non-objects

If someone serves a body that they expect to be of type number, all is well in the world.
But what if someone tests an API with that same config? What we get back from the API will most likely be a string. Is this supposed to try to parse that to a number, or whatever other type they want it to be to check the validity?

request.bodyPath

  • logic to get this feature working fully needs to be amended

request.bodyPath (pending changes)

  • Description: A path to the body you expect to make requests to the endpoint
    with. It must be a JSON file (should be updated to support other files in the
    future). Cannot be specified at the same time as request.body. Relative
    paths should be relative to the config file's location

    In Serve mode, if this property is specified without request.type, responses
    will only be served if the request body matches request.body

  • Type: string

  • Required?: No

  • Example: bodyPath: ./my-response.json or bodyPath: /some/absolute/path

Query strings

There has to be some better way to deal with query strings

For example: /api/v1/resource?greetings=hello&greetings=yo

I probably want the response for that address to be available no matter what order those query params come in.

request.headers

  • In Test Mode, call the endpoint with the headers
  • In Serve Mode, make sure the headers are present, otherwise respond with a 404

request.body

  • Make this work as described in serve mode
  • Make this work as described in test mode

Only create a type validator once it's required

Atm in test mode, the type validator gets created regardless of whether or not any configs contain Types. Hopefully the config re-write for test mode will fix this, but tracking here just in case.

  • Server mode
  • Test mode

Make the docs more clear

  • Update docs with usage suggestions for local development
  • Make the link to the Config documentation more clear
  • Update the example in the main readme to show 2 different configs

request.type

Make sure the type actually works like this and gives back a useful error message

  • Serve mode
  • Test mode

request.method

  • Add support for other HTTP methods

  • Does the 405 and allow header thing actually work?

  • Description: The HTTP method you would call the endpoint/s with. Currently,
    only GET and POST are supported

    In Serve mode, if the endpoint exists but is called with the wrong method, it
    will return a 405 response with an Allow header.

  • Type: string

  • Required?: Yes

  • Example:

    method: GET

request.serveEndpoint

  • Needs a sanity check

request.serveEndpoint (pending changes)

  • Description: An endpoint to serve the corresponding response. This
    supports ExpressJS string patterns
    (read more).
    Regex is not yet supported.

    This property is ignored in Test mode and overrides
    request.endpoints when in Serve mode.
  • Type: string
  • Required?: Required in Serve mode if request.endpoints is not provided
  • Example:
    serveEndpoint: /api/books/*

Update content negotiation for test mode

Right now, the http client will try to parse the response as JSON if the user has configured a response content-type of application/json

Really, it should base it on the request's accept header

Your .dependabot/config.yml contained invalid details

Dependabot encountered the following error when parsing your .dependabot/config.yml:

Automerging is not enabled for this account. You can enable it from the [account settings](https://app.dependabot.com/accounts/tamj0rd2/settings) screen in your Dependabot dashboard.

Please update the config file to conform with Dependabot's specification using our docs and online validator.

Find a way to let query params have any value

Obviously this should only use for the serveEndpoint value.

A wildcard * is probably a good character option. e.g

serveEndpoint: /api/resource?thingy=*

I feel like that should allow thingy to be any value or an array containing any values

Integration tests

It'd be great to finally have some of these.

Could create a basic express server that serves up some hardcoded responses and test using that. Then spy on console.log or winston or whatever to find out what the output was.

response.headers

  • In serve mode, respond with these headers
  • In test mode, check that these headers are received

response.headers (pending changes)

  • Description: The headers you expect to receive from the endpoint. Header
    names are case insensitive
  • Type: object
  • Required?: No
  • Example:
    headers:
      content-type: application/json
      Cache-Control: no-cache

request.endpoints

  • Sanity check for Serve
  • Sanity check for test

request.endpoints (pending changes)

  • Description: A single endpoint or list of endpoints that you'd like to
    test or serve.

    In Serve mode, if your configured endpoints contain a query string, responses
    will only be served if your request has matching query params. For example, in
    order to get responses for the configuration endpoints: /endpoint?size=5&size=6,
    you would need to make a request that include size=5 and size=6 as query
    params. If you leave either of them out of the request, your response will not
    be served and you'll receive a 400 status code. Providing extra params does not
    cause adverse effects.

  • Type: string or string[]

  • Required?: Required in Test mode if serveOnly is false

  • Example:

    endpoints: /my/endpoint
    # Or...
    endpoints:
      - /my/endpoint1
      - /my/endpoint2?hello=world # only served if request has query param "hello" with value "world"

response.type

This is possibly misleading. What does it actually do when string/number/boolean is given? HTTP responses are strings anyway. This should probably only allow string, object or a complex type.

  • Add [] syntax to expect an array of a certain type

response.type

  • Description: The name of a typescript symbol or a JSON schema file
    (excluding the .json). In Test mode, validation will be done between the actual
    response and the type. The test will fail if the body does not match the schema.
    In Serve mode, if body, bodyPath, serveBody or serveBodyPath are
    specified, validation will be done between the type and the mock response. If
    validation fails, you will receive an error and the mocks will not be served.
  • Type: string
  • Required?: No
  • Example: type: SomeInterfaceName

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.