-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch the URL request package from Request to Axios #170
- Loading branch information
1 parent
8d79e2c
commit 67548ea
Showing
3 changed files
with
43 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,31 @@ | ||
const request = require("request"); | ||
const axios = require('axios'); | ||
|
||
module.exports.assertion = function (negativeCase, expectedStatusCode) { | ||
|
||
return browser.url(function (currentURL) { | ||
browser.url(function (currentURL) { | ||
request(currentURL.value, (error, response, body) => { | ||
if (negativeCase) { | ||
return browser.assert.not.equal(response.statusCode, expectedStatusCode).end(); | ||
return axios.get(currentURL.value) | ||
.then(function (response) { | ||
browser.assert.equal(response.status, expectedStatusCode); | ||
}) | ||
.catch(function (error) { | ||
browser.assert.equal(error.status, expectedStatusCode); | ||
}) | ||
.finally(function () { | ||
// always executed | ||
}); | ||
} | ||
return browser.assert.equal(response.statusCode, expectedStatusCode).end(); | ||
return axios.get(currentURL.value) | ||
.then(function (response) { | ||
browser.assert.equal(response.status, expectedStatusCode); | ||
}) | ||
.catch(function (error) { | ||
browser.assert.equal(error.status, expectedStatusCode); | ||
}) | ||
.finally(function () { | ||
// always executed | ||
}); | ||
}); | ||
}); | ||
} | ||
} |
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
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