Commit 8e0cb95f authored by HUA YUEN HUI's avatar HUA YUEN HUI
Browse files

add unit tests

parent aa734df9
......@@ -7,6 +7,7 @@
// This application uses express as its web server
// for more info, see: http://expressjs.com
var express = require('express');
const message = require('./utils');
// cfenv provides access to your Cloud Foundry environment
// for more info, see: https://www.npmjs.com/package/cfenv
......@@ -25,5 +26,5 @@ var appEnv = cfenv.getAppEnv();
app.listen(appEnv.port, '0.0.0.0', function() {
// print a message when the server starts listening
console.log("server starting on " + appEnv.url);
console.log(message.getWelcomeMessage() + appEnv.url);
});
{
"name": "HelloWorldNodeApp",
"version": "0.0.1",
"private": true,
"private": true,
"scripts": {
"start": "node app.js"
"start": "node app.js",
"test-unit": "mocha test/unit-test.js --reporter json --reporter-options output=test/unit-test.json | tee test/unit-test.json"
},
"dependencies": {
"express": "4.17.x",
......@@ -12,5 +13,10 @@
"repository": {},
"engines": {
"node": "10.x || 12.x"
}
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^7.0.1",
"nyc": "*"
}
}
#!/bin/bash
# set -x
npm install
npm run test-unit
FILE_LOCATIONS="./test/unit-test.json"
TEST_TYPES="unittest"
\ No newline at end of file
const assert = require('assert');
const message = require('../utils');
describe('Message Test', () => {
it('Welcome Message', () => {
assert.strictEqual(message.getWelcomeMessage(), "server starting on ");
});
});
\ No newline at end of file
const welcomeMessage = "server starting on ";
const getWelcomeMessage = () => {
return welcomeMessage;
};
exports.getWelcomeMessage = getWelcomeMessage;
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment