Tell us what’s happening:
Hi all, I am passing all the tests except the last one. I am pretty sure I am doing something wrong/different than the tests expect, but I cannot figure out what exactly. The tests pass, they show up as passed here as well /_api/get-tests (I tried to get some info by looking at the network requests via the developer tools in chrome)
Your code so far
My test code is here - https://repl.it/@Aigarsss/boilerplate-project-issuetracker
Example of the first test:
test('Create an issue with every field: POST request to /api/issues/{project}', function(done) {
chai.request(server)
.post("/api/issues/apitest")
.set('content-type', 'application/json')
.send({
issue_title: "ToDelete",
issue_text: "issueText",
created_by: "createdBy",
assigned_to: "assignedTo",
status_text: "statusText"
})
.end(function(error, res){
res.should.have.status(200)
res.body.should.have.property("_id")
//https://www.digitalocean.com/community/tutorials/test-a-node-restful-api-with-mocha-and-chai
done();
});
});
I am not sure how to trouble shoot this, as obviously I could just pass the tests by just doing “done” in all of them, so I assume FCC checks are looking for specific things there?
When I submit, this is what I get in the console: At least one assertion per test: expected 0 to be at least 1
This part might not be correct, but I am not sure how to correctly write it:
test('Delete an issue: DELETE request to /api/issues/{project}', async function() {
const toDelete = await Issue.findOne({issue_title: "ToDelete"}).exec()
chai.request(server)
.delete("/api/issues/apitest")
.send({_id: toDelete._id}) // how to generate new id every time?
.end(function(error, res){
res.body.should.have.property("result").eql("successfully deleted")
//done(); //https://stackoverflow.com/questions/41761683/why-am-i-getting-error-resolution-method-is-overspecified
});
});
And one last thing, when I run the FCC tests, i get “undefined” in the repl console. I looked at other FCC posts, seems like for other people it was caused by calling “done()” outside of .end, but it doesn’t seem to be the case here.
Challenge: Issue Tracker
Link to the challenge: