I wasn’t having any trouble before however even the sample test given isn’t passing now, however when i test with Insomnia or use with Axios in my react app they both work fine.
is there anything additional i need to do / change to make this work with my setup when express is running from localhost port 5000, I’m still connecting to mongo Atlas.
Test Code
test('#example Test GET /api/books', function(done){
chai.request(server)
.get('/api/books')
.end(function(err, res){
assert.equal(res.status, 200);
assert.isArray(res.body, 'response should be an array');
assert.property(res.body[0], 'commentcount', 'Books in array should contain commentcount');
assert.property(res.body[0], 'title', 'Books in array should contain title');
assert.property(res.body[0], '_id', 'Books in array should contain _id');
done();
});
});
Response when get request is sent to localhost:5000/api/books
[
{
"comment": [],
"_id": "5e66a31ec347278a4cc146eb",
"title": "book1",
"commentCount": 0,
"__v": 0
},
{
"comment": [],
"_id": "5e66a322c347278a4cc146ec",
"title": "book2",
"commentCount": 0,
"__v": 0
},
{
"comment": [],
"_id": "5e66a326c347278a4cc146ed",
"title": "book3",
"commentCount": 0,
"__v": 0
}
]