Skip to content

Instantly share code, notes, and snippets.

@AlexanderMoskovkin
Created December 13, 2017 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexanderMoskovkin/79a8d1daa864b56de2ef1be53a176c55 to your computer and use it in GitHub Desktop.
Save AlexanderMoskovkin/79a8d1daa864b56de2ef1be53a176c55 to your computer and use it in GitHub Desktop.
make request
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