I'm going off of this tutorial, trying to make tests with Mocha, Supertest, and Should.js.
I have the following basic test to create a user through a PUT
endpoint that accepts it's data in headers.
describe('User Routes', function () {
it('should allow me to make my user', function (done) {
request(url)
.put('/users')
.set(myCreds)
// end handles the response
.end(function(err, res) {
if (err) {
throw err;
}
// this is should.js syntax, very clear
res.should.have.status(201);
done();
});
});
However, while the endpoint does trigger, and the user does get made, the code throws an error that should
is undefined... Uncaught TypeError: undefined is not a function
.
I have
var should = require('should');
var assert = require('assert');
var request = require('supertest');
At the top of the file, so why would it be undefined?