Giter Club home page Giter Club logo

Comments (6)

JonWallsten avatar JonWallsten commented on May 18, 2024 1

And as a feature request it would be cool if you could use different success files for different params.
Like success{id}.json and the you name the files success1.json, success2.json, and so on!

from node-mock-server.

smollweide avatar smollweide commented on May 18, 2024

@JonWallsten Currently it's just possible to use query params as ejs variables query param in ejs

I will add the dynamic path to ejs object.
The solution (with future version 0.7.2 #9) will be:

{
      "id": <%=params.id%>,
      name: "<%-faker.name.firstName();%>"
}

You question about how to change the mock response:

  • Change the expected response by using the UI
    expected-response-ui
  • Use the query param _expected=error
  • Use the request header _expected=error

Expected response

An automatic check for not existing dynamic path is currently not implemented #8 .

from node-mock-server.

JonWallsten avatar JonWallsten commented on May 18, 2024

Cool! Then I'll wait for the next release.

Ah, i see! I thought it could be done automagically! ;)
Thanks!

from node-mock-server.

JonWallsten avatar JonWallsten commented on May 18, 2024
{
    "id": 1,
    "campaignId": <%=id%>,
    "name": "Test"
}

I get a reference error:
"id" is not defined.
path: undefined.
Is it because I'm using /rest/test/1 instead of /rest/test/?id=1 ?

from node-mock-server.

smollweide avatar smollweide commented on May 18, 2024

@JonWallsten
Yes that's because you use /rest/test/1 instead of /rest/test/?id=1
0.7.2 is released - npm install [email protected]
which includes the two issues, has arisen from your questions.

With the new release you can use this:

{
      "id": <%=params.id%>,
      name: "<%-faker.name.firstName();%>"
}

I hope it works as you had assumed.
Thanks for your feedback and questions.

from node-mock-server.

JonWallsten avatar JonWallsten commented on May 18, 2024

Thank you! That's awesome!

from node-mock-server.

Related Issues (20)

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.