Merge pull request #181 from heroku/replace-request-with-got

replace deprecated request with got
main
Lillian Zhang 4 years ago committed by GitHub
commit a8ca3c56bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -15,7 +15,7 @@
"express": "^4.15.2"
},
"devDependencies": {
"request": "^2.81.0",
"got": "^11.3.0",
"tape": "^4.7.0"
},
"repository": {

@ -1,5 +1,5 @@
const { spawn } = require('child_process');
const request = require('request');
const got = require('got');
const test = require('tape');
// Start the app
@ -12,17 +12,17 @@ test('responds to requests', (t) => {
// Wait until the server is ready
child.stdout.on('data', _ => {
// Make a request to our app
request('http://127.0.0.1:5000', (error, response, body) => {
(async () => {
const response = await got('http://127.0.0.1:5000');
// stop the server
child.kill();
// No error
t.false(error);
t.false(response.error);
// Successful response
t.equal(response.statusCode, 200);
// Assert content checks
t.notEqual(body.indexOf("<title>Node.js Getting Started on Heroku</title>"), -1);
t.notEqual(body.indexOf("Getting Started on Heroku with Node.js"), -1);
});
t.notEqual(response.body.indexOf("<title>Node.js Getting Started on Heroku</title>"), -1);
t.notEqual(response.body.indexOf("Getting Started on Heroku with Node.js"), -1);
})();
});
});

Loading…
Cancel
Save