fac-15 / SSKM

Week 8

Home Page:https://sskm-tech.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

✅ Server tesing

astroash opened this issue · comments

commented

test("technology is getting a status of 200", t => {
request(app)
.get("/technology/:name")
.end((err, res) => {
if (err) {
return `You have an error: ${err}`;
} else {
t.equal(res.status, 200);
t.end();
}
});
});

If you do not get 200 this test will pass. You want to make sure that your test runner is throwing an error if you do not get the expectation you want. To do this you can write a test that expects err to be false. eg:

test("technology is getting a status of 200", t => { 
   request(app) 
     .get("/technology/:name") 
     .end((err, res) => { 
         t.false(err); 
         t.equal(res.status, 200); 
         t.end(); 
       } 
     }); 
});