7 ms·
Mock your HTTP responses to test your REST API
- vodkaflo 13y ago
- misframer 13y agoI'm occasionally getting hit with "HTTP/1.1 500 Internal Server Error" when that's not what I want.
- yotsumi 13y ago@misframer The app is updated in real time. So it can be some sporadic errors
- quarterto 13y agoWelcome to Hacker News. We don't have @replies here. We do, however, have nice friendly reply buttons. Great app, by the way!
- gulbrandr 13y agohttp://www.hurl.it/ http://www.hurl.it/ I recommend this service for this kind of testing.
- quarterto 13y agoHurl is requests. Mocky is responses.
- quarterto 13y agoIn fact, here is Mocky serving a response to Hurl: http://www.hurl.it/hurls/18e4da3bfc0c2159abd1c8e769915c360a8de8ce/6dc5f86a8ac115dc0870e88cf260d5b7dcb49c15 http://www.hurl.it/hurls/18e4da3bfc0c2159abd1c8e769915c360a8...
- farmdawgnation 13y agoIf a hurl falls in a forest, and only a mocky is around to hear it, did it happen?
- jstoja 13y agoThat's cool !
- PuercoPop 13y agoNice, Emacs have a mode for doing the same too: https://github.com/pashky/restclient.el https://github.com/pashky/restclient.el
- yotsumi 13y agoEmacs have a REST Client, but this app is like a REST Server: Mocky serve an HTTP response, whereas RestClient send an HTTP resquest.
- untog 13y agoIt's a nice idea, but relying on a remote service for testing makes me worry. I tend to mock HTTP responses locally, so that the tests can run when there isn't even an internet connection available.
- jrochkind1 13y agoI use ruby [vcr](https://github.com/vcr/vcr https://github.com/vcr/vcr) to mock responses. But ordinarily it 'records' an actual HTTP interaction, to play it back latter mock. If you want to mock something you don't currently have conveniently 'live' to record, you can try to write up the serialized recorded request by hand -- but it'd be a lot easier to use this service to mock up a request, then record it with VCR so subsequent test runs don't go out to the network. I plan to do some of that, as needed. Convenient.
- yotsumi 13y agoYes, you are absolutely right. But sometimes is a good idea to test somes WS requests across all the network, in addition of your locally mocked tests.
- johns 13y agoWhat do you use for your local testing?
- fein 13y agoTelnet when I'm lazy or its quick, curl when I actually want to write a full harness.
- rcoh 13y agoIronically, I'm seeing 500s. Great for testing my reliability in the face of errors!
- yotsumi 13y agoYes sorry for that, I didn't expect a such traffic from HN. Things will be stable in a few hours :)
- city41 13y agoIt's a neat idea but I can't imagine I'd ever actually use this for real testing. Relying on a third party server for your tests can be a problem. We also have thousands of tests that rely on mocked REST responses, setting them up with Mocky would be a ton of work. If Mocky could be ran onsite and had a nice API for easily generating mock responses, then I think it would be more useful.
- yotsumi 13y agoIt's an open source project, created 2 days ago. All is possible, this website is just a proof of concept. And you can fork the project to run it locally.
- city41 13y agoYeah I realize that. I hope I didn't come across too harsh. It is a good idea, and I'd like to see it grow some more.
- johns 13y agoWhat do you use for your existing tests? VCR?
- city41 13y agoWe've rolled our own system inside Jasmine that mocks out XHR. It's generally in the form of: @ajax.whenQuerying('someendpoint').respondWith(someData) And internal to that system we have some components that understand the overall shape of our data model so someData can be a very small, simple object with just the data the test cares about and the internals flesh out the rest.
- thekingshorses 13y agoThis failed :( <div>what</div><div>Not</div>this<ul id="list" data-list="f"><li class="first">one</li></ul>
- antonpug 13y agoHow exactly does this work? A short little tutorial would help ^.^
- rajanikanthr 13y agoI use mocking framework(Moq for .NET) to mock my service response and various xml responses i will save in test xml files.. Anyways, I will try to use it to test over network rather local mocking
- alpb 13y agoNice project! My suggestion would be adding JSON editor or JSON syntax validator for JSON responses saved.
- yotsumi 13y agoYou already have a light Json editor. The Syntax validation is a very good idea, thanks!
- deleted 13y ago[deleted]
- bruth 13y agoNice idea. Are these stored as gists under my account? Can I choose to modify an existing response so it's versioned?
- wilig 13y agoFor those looking for a local alternative have a look at http://wilig.github.io/mockity/ http://wilig.github.io/mockity/ Full disclosure: I'm the author.
- rco8786 13y agoBeen working on something similar for local use by running nodejs to both server static files and mock API responses. https://github.com/rco8786/apimok https://github.com/rco8786/apimok
- donatj 13y agoI use http://frisbyjs.com/ http://frisbyjs.com/ FrisbyJS for most of my front end API testing needs.
- guyht 13y agoI have wanted a service like this forever! Thank you.
- aespinoza 13y agoThis is very cool. It is kind of a fiddler on the web. It is interesting that I saw something similar but with fiddler in the morning: http://www.devcurry.com/2013/05/testing-crud-operations-in-aspnet-web_3.html http://www.devcurry.com/2013/05/testing-crud-operations-in-a...
- sinkingfish 13y agoI just launched something almost exactly the same a fortnight ago - e.ndpoint.com - POST/PUT/DELETE support coming soon.
- johns 13y agoThe URL scheme you're using makes it really easy to view everyone else's mocks.
- sinkingfish 13y agoYea i'm not looking to obfuscate, I'm planning on introducing user accounts whereby people by create, save, edit, and alias their mocks. Bypassing that issue. Anonymous mocks will simply be sequential base62.
- tjpd 13y agoI've heard good things about http://apiary.io http://apiary.io on this front as well...
- nyam 13y agoi'm using it on first project and it's very nice. they let you export your complete api definition to apiary.apib file which can be parsed with their github.com/apiaryio/blueprint-parser into json and used with your custom server localy. it's also nice for synchronizing between devs, when added to vcs ...
- ericmoritz 13y agothis isn't any better than using a live server for testing. Build a good client library for your applications to use, mock the client library and don't worry about tests failing because of availability problems.
- johns 13y agoIf the live server has side effects when making the call (send an email, charge a card, etc) and you just want to test against the response headers/body, it can be very useful. A local mocking library is also good for that, but for quicker tests this is nice.
- memoryfault 13y agoWould someone provide an example on how this tool could be used to test a REST API? I think I'm missing something here. I'm not seeing how a fake response endpoint lets me test my REST API (shouldn't my test code invoke the API and validate that the real response was correct?)
- xoail 13y agoOne usecase I can think of is when UI developers are working on a set of expected response from an API while the API is currently being developed by backend developers. Once the API is ready, UI devs can swap the uri.
- sanderjd 13y agoIt seems to me that it isn't for testing a REST API but rather for testing something that depends on one without having to deal with real integration issues.
- yotsumi 13y agoYes, you explain better than me ;)
- Millennium 13y agoYour test code should invoke the real API if it's testing the real API. If you're testing a REST client, on the other hand, then it's best to unit test on a controlled set of requests and responses. Testing on the real API comes later, when you're doing integration.
- simons 13y agoThere's a post here: http://artemave.github.io/2012/05/27/stub-like-a-surgeon-spy-like-james-bond-with-rest-assured/ http://artemave.github.io/2012/05/27/stub-like-a-surgeon-spy... that talks about using a similar service (the BBC's REST-assured https://github.com/BBC/REST-assured https://github.com/BBC/REST-assured) to aid in BDD using cucumber.
- jnettome 13y agoI've sent a pull request to add portuguese brazilian translation. I hope it helps! Scala is really cool :)
- rross 13y agoE.endpoint.com A very similar offering released a week ago on github.
- nym 13y agoYou can't mock HTTP responses, the responses mock you. http://www.flickr.com/photos/girliemac/6508102407/in/set-72157628409467125/ http://www.flickr.com/photos/girliemac/6508102407/in/set-721...
- rschmitty 13y agoWhy not use SinonJS? http://sinonjs.org/ http://sinonjs.org/ Same ability to mock responses and errors, but everything is local. Check your responses into git and every developer is testing the same stuff, no reliance on a 3rd party Makes for lightning fast automatic background testing.
- kanzure 13y agoAlso, python people might be interested in https://github.com/gabrielfalcao/HTTPretty https://github.com/gabrielfalcao/HTTPretty or (bias disclaimer) my serializer on top of requests+httpretty https://github.com/kanzure/python-requestions https://github.com/kanzure/python-requestions for the httpetrified decorator. It loads and mocks an expected response from a json file in your tests/. There was a service called requests.in or something that acted like httpbin, except it gave you a unique url to query against to view multiple requests over a session. Does anyone know where that went?
- johns 13y agorequestb.in
- gstroup 13y agoI prefer to run my own local test server to return mock responses. I built this little project, that you can install using NPM: https://npmjs.org/package/apimocker https://npmjs.org/package/apimocker It's intended for sandbox development as well as automated tests. There's no UI, but you can return whatever data you want. The features are pretty basic right now, but it works well for most tests, and it's easily configured on the fly.
- meryn 13y agoWouldn't it be better if it would just say "mock your HTTP responses to test your HTTP client", or "to test your HTTP client code"? The service makes a lot of sense otherwise.
- austengary 13y agoIn case anyone was wondering about licensing: "[1]DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2004 Sam Hocevar sam@hocevar.net" [1] https://github.com/studiodev/Mocky https://github.com/studiodev/Mocky