Skip to content

Instantly share code, notes, and snippets.

@jwo

jwo/app.js

Created Jul 10, 2017
Embed
What would you like to do?
Simple example for testing an HTML endpoint in node with supertest and chai. Most examples only test API endpoints it seems.
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;
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