Jestem nowy w mocha i should.js. Próbuję sprawdzić stan odpowiedź, ale to daje mi TypeError: Object #<Assertion> has no method 'status'
Kod jest tak:res.should.have.status daje mi błąd
describe('Local signup', function() {
it('should return error trying to save duplicate username', function(done) {
var profile = {
email: '[email protected]',
password: 'Testing1234',
confirmPassword: 'Testing1234',
firstName: 'Abc',
lastName: 'Defg'
};
request(url)
.post('/user/signup')
.send(profile)
.end(function(err, res) {
if (err) {
throw err;
}
res.should.have.status(400);
done();
});
});
Zauważyłem również, że choć zadeklarowały var should = require('should');
, mój ide powiadamia mnie, że „powinien” jest nieużywany zmiennej lokalnej . Naprawdę nie wiem dlaczego.
Czy używasz tego w przeglądarce? – plalx
@plalx Oznaczone przez 'node.js'. –
@YuryTarabanko Wiem, ale w dokumentach jest napisane, że 'status' nie jest częścią kompilacji przeglądarki, więc nabrałem podejrzeń. – plalx