Created
December 13, 2017 05:36
-
-
Save AlexanderMoskovkin/79a8d1daa864b56de2ef1be53a176c55 to your computer and use it in GitHub Desktop.
make request
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
import request from 'request'; | |
const getResponseStatusCode = link => { | |
return new Promise(resolve => { | |
request(link, function (error, response, body) { | |
console.log('error:', error); // Print the error if one occurred | |
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received | |
console.log('body:', body); // Print the HTML for the Google homepage. | |
resolve(response && response.statusCode); | |
}); | |
}); | |
} | |
// in your test | |
const documentLink = 'http://my-document-link.com'; | |
const statusCode = await getResponseStatusCode(documentLink); | |
await t.expect(statusCode).eql(200); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment