Comments (11)
Pretty nice idea! Give me some time to figure out the way to make it out.
from superagent-mocker.
Great!
from superagent-mocker.
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.
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.
from superagent-mocker.
@avanderhoorn do you want make pull request? :D
from superagent-mocker.
Ya, might be up for it, how would you want the API to look?
from superagent-mocker.
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.
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.
@avanderhoorn published with 0.2.0
from superagent-mocker.
Fantastic! Which commit # was it?
from superagent-mocker.
9db610c but still without ability to setup it for endpoint. You can make PR for it.
from superagent-mocker.
Related Issues (20)
- Cannot mock requests created with superagent constructor. HOT 2
- Request Headers are lowercased
- Types are not respected in the mock endpoint req.body
- can't get query string HOT 3
- Maybe it's a bug~ HOT 1
- Compatibility with superagent-bluebird-promise
- Invalid status check HOT 1
- Aborting requests
- unmock takes an argument HOT 2
- Superagent now supports subclassing
- request.agent() is not patched
- Double call callback HOT 1
- Abandoned? HOT 1
- MIT License HOT 2
- Query with array parameters aren't captured correctly
- Incorrect mocking of `req.query`.
- Confusing documentation
- #9
- Sunami
- Unemployment rates in Ghana HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from superagent-mocker.