mirror of
https://github.com/microsoft/TypeScript-Node-Starter.git
synced 2025-11-08 16:17:37 +00:00
coverage/chai support and some unit tests
1. added jest coverage support (#64) 2. added chai testing support 3. created new unit tests
This commit is contained in:
committed by
Bowden Kelly
parent
780e30826c
commit
d080f39b86
53
package-lock.json
generated
53
package-lock.json
generated
@@ -588,6 +588,12 @@
|
||||
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
|
||||
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
|
||||
},
|
||||
"assertion-error": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.2.tgz",
|
||||
"integrity": "sha1-E8pRXYYgbaC6xm6DTdOX2HWBCUw=",
|
||||
"dev": true
|
||||
},
|
||||
"astral-regex": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz",
|
||||
@@ -1204,6 +1210,20 @@
|
||||
"lazy-cache": "1.0.4"
|
||||
}
|
||||
},
|
||||
"chai": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz",
|
||||
"integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"assertion-error": "1.0.2",
|
||||
"check-error": "1.0.2",
|
||||
"deep-eql": "3.0.1",
|
||||
"get-func-name": "2.0.0",
|
||||
"pathval": "1.1.0",
|
||||
"type-detect": "4.0.5"
|
||||
}
|
||||
},
|
||||
"chalk": {
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz",
|
||||
@@ -1233,6 +1253,12 @@
|
||||
"is-regex": "1.0.4"
|
||||
}
|
||||
},
|
||||
"check-error": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",
|
||||
"integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=",
|
||||
"dev": true
|
||||
},
|
||||
"chokidar": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz",
|
||||
@@ -1597,6 +1623,15 @@
|
||||
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
|
||||
"integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA="
|
||||
},
|
||||
"deep-eql": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz",
|
||||
"integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"type-detect": "4.0.5"
|
||||
}
|
||||
},
|
||||
"deep-extend": {
|
||||
"version": "0.4.2",
|
||||
"resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz",
|
||||
@@ -2254,6 +2289,12 @@
|
||||
"integrity": "sha1-9wLmMSfn4jHBYKgMFVSstw1QR+U=",
|
||||
"dev": true
|
||||
},
|
||||
"get-func-name": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz",
|
||||
"integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=",
|
||||
"dev": true
|
||||
},
|
||||
"get-stdin": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz",
|
||||
@@ -5360,6 +5401,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"pathval": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz",
|
||||
"integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=",
|
||||
"dev": true
|
||||
},
|
||||
"pause": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz",
|
||||
@@ -7026,6 +7073,12 @@
|
||||
"prelude-ls": "1.1.2"
|
||||
}
|
||||
},
|
||||
"type-detect": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.5.tgz",
|
||||
"integrity": "sha512-N9IvkQslUGYGC24RkJk1ba99foK6TkwC2FHAEBlQFBP0RxQZS8ZpJuAZcwiY/w9ZJHFQb1aOXBI60OdxhTrwEQ==",
|
||||
"dev": true
|
||||
},
|
||||
"type-is": {
|
||||
"version": "1.6.15",
|
||||
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz",
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"serve": "node dist/server.js",
|
||||
"watch-node": "nodemon dist/server.js",
|
||||
"watch": "concurrently -k -p \"[{name}]\" -n \"Sass,TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-sass\" \"npm run watch-ts\" \"npm run watch-node\"",
|
||||
"test": "jest --forceExit",
|
||||
"test": "jest --forceExit --coverage --verbose",
|
||||
"build-ts": "tsc",
|
||||
"watch-ts": "tsc -w",
|
||||
"build-sass": "node-sass src/public/css/main.scss dist/public/css/main.css",
|
||||
@@ -73,8 +73,9 @@
|
||||
"@types/passport-facebook": "^2.1.3",
|
||||
"@types/request": "^2.0.9",
|
||||
"@types/supertest": "^2.0.4",
|
||||
"concurrently": "^3.5.1",
|
||||
"@types/shelljs": "^0.7.7",
|
||||
"chai": "^4.1.2",
|
||||
"concurrently": "^3.5.1",
|
||||
"jest": "^21.2.1",
|
||||
"node-sass": "^4.7.2",
|
||||
"nodemon": "^1.13.0",
|
||||
|
||||
@@ -1,9 +1,27 @@
|
||||
import * as request from "supertest";
|
||||
import * as app from "../src/app";
|
||||
|
||||
var chai = require('chai');
|
||||
var expect = chai.expect;
|
||||
|
||||
describe("GET /contact", () => {
|
||||
it("should return 200 OK", (done) => {
|
||||
request(app).get("/contact")
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("POST /contact", () => {
|
||||
it("should return false from assert when no message is found", (done) => {
|
||||
request(app).post("/contact")
|
||||
.field("name", "John Doe")
|
||||
.field("email", "john@me.com")
|
||||
.end(function(err, res) {
|
||||
expect(res.error).to.be.false;
|
||||
done();
|
||||
})
|
||||
.expect(302);
|
||||
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,9 @@
|
||||
import * as request from "supertest";
|
||||
import * as app from "../src/app";
|
||||
|
||||
var chai = require('chai');
|
||||
var expect = chai.expect;
|
||||
|
||||
describe("GET /login", () => {
|
||||
it("should return 200 OK", () => {
|
||||
return request(app).get("/login")
|
||||
@@ -14,3 +17,18 @@ describe("GET /signup", () => {
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("POST /login", () => {
|
||||
it("should return some defined error message with valid parameters", (done) => {
|
||||
return request(app).post("/login")
|
||||
.field("email", "john@me.com")
|
||||
.field("password", "Hunter2")
|
||||
.expect(302)
|
||||
.end(function(err, res) {
|
||||
expect(res.error).not.to.be.undefined;
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user