Skip to content

Instantly share code, notes, and snippets.

@danizavtz
Last active May 13, 2020 19:47
Show Gist options
  • Save danizavtz/1ebc8bf698d4cfe9d097fc8f8812b447 to your computer and use it in GitHub Desktop.
Save danizavtz/1ebc8bf698d4cfe9d097fc8f8812b447 to your computer and use it in GitHub Desktop.
let tokn = null //essa é variável global durante a execução dos testes que irá armazenar o token
...
before(function(done) {
api.post('/ingefood/login')
.send({
"login": "teste",
"password": "essaéaminhasenhasuperseguraparaseauthenticarnestaapi."
})
.expect(200)
.end(function(err, res) {
tokn = res.body;
done();
});
});
...
it('Return all categories instances', function(done) {
api.get(_url)
.set('Authorization', 'Bearer '+tokn)
.expect(200)
.end(function(err, res) {
expect(res.body).to.be.instanceof(Array);
expect(res.body.length).to.equal(1);
done();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment