JumpStart – Testing our Express server (supertest)

put/ patch (implementation is up to server)
Supertest uses superagent to use html methods (.post, .query({format:’json’})

Using jest expect (green indicates jest expect):

.expect(202)
.then(res => {
expect(res.body.id).toEqual(expect.any(String));
expect(res.body.name).toEqual(“Alfred”);
expect(res.body.subjects).toEqual(expect.any(Array));
});

versioning exists in api
app.use(“/app/v1….”)

For… in loops over prototype chain as well (eg: objects constructed from class)
so use
Object.entries [[k,v], [k,v]]
Object.keys [k,k,k]

Leave a comment

Design a site like this with WordPress.com
Get started