Code Monkey home page Code Monkey logo

Comments (11)

A avatar A commented on May 26, 2024

Pretty nice idea! Give me some time to figure out the way to make it out.

from superagent-mocker.

avanderhoorn avatar avanderhoorn commented on May 26, 2024

Great!

from superagent-mocker.

A avatar A commented on May 26, 2024

Yay! @avanderhoorn, is it ok for you?

var mock = require('superagent-mocker');

// set just number
mock.timeout = 100;

// Or function to get random
mock.timeout = function () {
  return Math.random() * 1e4 |0;
}

https://github.com/rambler-digital-solutions/superagent-mocker#timeout

from superagent-mocker.

avanderhoorn avatar avanderhoorn commented on May 26, 2024

Yep that is nice! I had originally thought about it being configurable on an endpoint by endpoint basis so endpoints that take longer than other, etc could be accounted for but I'll take what I can get and having it work globally does save having to manually setup each one. I also like being able to pass in a function instead of just a int, so nice touch there. :shipit:

from superagent-mocker.

A avatar A commented on May 26, 2024

@avanderhoorn do you want make pull request? :D

from superagent-mocker.

avanderhoorn avatar avanderhoorn commented on May 26, 2024

Ya, might be up for it, how would you want the API to look?

from superagent-mocker.

A avatar A commented on May 26, 2024

Awesome! What do you think about chained API like superagent?

require('superagent-mocker')
  .get('/topics/:id', function(req) {
    return {
      id: req.params.id,
      content: 'Hello World!'
    };
  })
  .timeout(100)
  // or
  .timeout(function() { return Math.random() * 1e4 |0; })

from superagent-mocker.

A avatar A commented on May 26, 2024

btw, I can release new version with mock.timeout, but if you want to add ability to set timeout to each endpoint, I will wait your PR before

from superagent-mocker.

A avatar A commented on May 26, 2024

@avanderhoorn published with 0.2.0

from superagent-mocker.

avanderhoorn avatar avanderhoorn commented on May 26, 2024

Fantastic! Which commit # was it?

from superagent-mocker.

A avatar A commented on May 26, 2024

9db610c but still without ability to setup it for endpoint. You can make PR for it.

from superagent-mocker.

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.