Quickly create fake APIs for use in client-only tests or prototypes.
People
Repo info
Activity
Daniel Hough
@basicallydan
Hey @dmart120 glad you're finding it useful. It should do, yeah. It does wildcard CORS out of the box. Are you finding the Access-Control-Allow-Origin header is not set when responses come back?
dmart120
@dmart120
i don't get any responses at all. chrome shows the request method as OPTIONS, but the request header has Access-Control-Request-Method:GET. i'm not sure why chrome says the request method is OPTIONS?
dmart120
@dmart120
@basicallydan
Daniel Hough
@basicallydan
Hey @dmart120 sorry I totally missed your messages!
Lemme have a look at lunch, see if anything has changed
dmart120
@dmart120
@basicallydan thanks! let me know if you find anything
Daniel Hough
@basicallydan
I think I know why this is happening. Interfake accepts requests wildcard for method and path, so the OPTIONS request that chrome is probably making beforehand is being returned as the default, which is GET. Someone opened an issue relating to OPTIONS not being supported, and has offered to fix it, which should also solve this problem :)
Daniel Hough
@basicallydan
@dmart120 Is your version of Interfake up-to-date?
Because OPTIONS requests actually don't seem to work at all, which now makes sense
ddperdue
@ddperdue
@basicallydan Hello, I've been having trouble getting serveStatic to work. I basically copy and pasted the example code in, but I'm always getting a 404 response when I visit localhost:3000/static/index.html . The html file is in the same folder as my interfake code. Everything is working when I use the interfake.get().body() type examples but the serveStatic doesn't work for me. Any thoughts on why this would not be working? Thanks for any help you can provide.
Jon Denly
@jdenly
@ddperdue I had a similar issue when I was trying to mix together serveStatic and other mappings at the same time. The solution I found was to separate out the first part of the URL to make sure there was no overlap between the static mappings and the non-static, otherwise interfake was trying to find the static mapping in the normal routes.
// Have to provide a path so it doesn't clash with the static serving.var interfake = new Interfake({path: '/api'});
interfake.serveStatic('/static', './');
Todd Pickell
@tapickell
Hey, was wondering if there is a way to output the json payload received from a POST request with interfake?
Was thinking of using this as a simple way to make some assertions against the response.
Daniel Hough
@basicallydan
Not built in, no, but I've received this request before. Might be an easy feature to do... Could just be like .post('/thing').echo(), how does that sound?
@jdenly, having problems with servestatic for a while
Been meaning to fix but have been on holiday, I was hoping to fix it today :)