Last active
August 1, 2019 14:44
-
-
Save clarkdave/5857265 to your computer and use it in GitHub Desktop.
How to make arbitrary POST requests using Zombie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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