Skip to content

Instantly share code, notes, and snippets.

@clarkdave
Last active August 1, 2019 14:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clarkdave/5857265 to your computer and use it in GitHub Desktop.
Save clarkdave/5857265 to your computer and use it in GitHub Desktop.
How to make arbitrary POST requests using Zombie
var browser = new Browser();
browser.visit('/hello', function() {
// do some checks
// I'm not sure if browser.resources is an official part of the Zombie API (I found it by searching the src)
// so be wary in case it changes
browser.resources.post(
'/authenticate?email=hello@example.com&password=' + auth_token,
{ headers: {'Accept': 'application/json'} },
function(err, res) {
res.statusCode.should.equal(201);
// you can check cookies here, and keep requesting more pages as needed
done();
});
// it's possible to also do PUT and DELETE requests:
browser.resources.request("PUT", '/url', options, callback);
browser.resources.request("DELETE", '/url', options, callback);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment