njsetn:checking_server_responses_with_cheerio
→ Check the data that get returned
// app-spec.js
(...)
var cheerio = require("cheerio");
(...)
it("Loads the home page", function(done) {
request(app).get("/").expect(200).end(function(err, res) {
var $ = cheerio.load(res.text);
var pageHeading = $("body>h1:first-child").text();
expect(pageHeading).to.equal("Skier Dictionary");
});
});
(...)
it("GETS dictionary-api", function(done) {
var defs = this.defs;
request(app).get("/dictionary-api").expect(200).end(function(err, res) {
var terms = JSON.parse(res.text);
expect(terms).to.deep.equal(defs);
done();
});
});
(...)
njsetn/checking_server_responses_with_cheerio.txt · Last modified: 2016/03/28 17:50 by leo