let testUser = {username: 'test-user', password: 'test-pass'};
app.use('/api/signup', signup); //this is the route in express
before( done => {
request.post('/api/signup')
.send(testUser)
.then( result => {
const resultObj = JSON.parse(result.res.text);
console.log(resultObj);
testUser.token = resultObj.token;
testUser.id = resultObj.id;
return Promise.all([
request.post('/api/installments').set('token',testUser.token).send(testInstallment),
request.post('/api/installments').set('token',testUser.token).send(testInstallment1)
]);
})
.then( result => {
testInstallment = JSON.parse(result[0].text);
testInstallment1 = JSON.parse(result[1].text);
done();
})
.catch( err => {
done(err);
});
});
I am trying to test for the signup of a new user. This test had been previously passing, and the functionality even currently works in chrome and postman, but for some reason I can't pass this before test. I keep getting 400 bad request.
I have commented out the code in the .then() to simply see if I could log result, but even that gave me a 400 error. I quite simply don't know what I could have possibly done to get this error.
Aucun commentaire:
Enregistrer un commentaire