Created
July 10, 2017 14:40
-
-
Save jwo/77656e9945cb3fe426b535c97889f554 to your computer and use it in GitHub Desktop.
Simple example for testing an HTML endpoint in node with supertest and chai. Most examples only test API endpoints it seems.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const mustache = require("mustache-express"); | |
const bodyParser = require("body-parser"); | |
const app = express(); | |
// Rest of the stuff here | |
// DONT FORGET THIS | |
module.exports = app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require("supertest"); | |
const assert = require("chai").assert; | |
const app = require("../app"); | |
describe("GET /", function(){ | |
it("is 200", function(done){ | |
request(app) | |
.get("/") | |
.expect("Content-type",/html/) | |
.expect(200) | |
.end(function(err, res){ | |
assert.include(res.text, "Games") | |
done() | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment