DEV Community

Jose A. Vallejo
Jose A. Vallejo

Posted on

Jasmine makes easy unit test for you api

var request = require('request');
beforeEach(() => {
Bicicleta.allBicis = [];
console.log("Ejecutando test...");
})

/* test nested for the api funcionality check */
describe("test API Bicicletas", () => {
describe("Test GET", () => {
it("code status and body", () => {
request.get('http://localhost:3000/api/bicicletas', function (error, res, body) {
expect(res.statusCode).toBe(200);
expect(JSON.parse(body)['bicicletas'].length).toBe(0)
});
});
});
});

Top comments (0)