Setup testing
This commit is contained in:
parent
90345efd26
commit
b008e9088a
4 changed files with 24 additions and 2 deletions
|
@ -3,4 +3,4 @@ image: node
|
||||||
all_tests:
|
all_tests:
|
||||||
script:
|
script:
|
||||||
- npm install
|
- npm install
|
||||||
- node app.js
|
- npm test
|
||||||
|
|
2
app.js
2
app.js
|
@ -54,3 +54,5 @@ io.on("connection", (socket) => {
|
||||||
request.end();
|
request.end();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
module.exports = server;
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
"description": "Internet security awareness campaigns",
|
"description": "Internet security awareness campaigns",
|
||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"start": "node app.js",
|
||||||
|
"test": "./node_modules/.bin/mocha"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -17,5 +18,10 @@
|
||||||
"morgan": "^1.10.0",
|
"morgan": "^1.10.0",
|
||||||
"pug": "^2.0.4",
|
"pug": "^2.0.4",
|
||||||
"socket.io": "^2.3.0"
|
"socket.io": "^2.3.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"chai": "^4.2.0",
|
||||||
|
"mocha": "^7.2.0",
|
||||||
|
"request": "^2.88.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
test/test-pages.js
Normal file
14
test/test-pages.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
const expect = require("chai").expect;
|
||||||
|
const request = require("request");
|
||||||
|
const server = require("../app");
|
||||||
|
|
||||||
|
it("Main page content", (done) => {
|
||||||
|
request("http://localhost:8080" , function(error, response) {
|
||||||
|
expect(response.statusCode).to.equal(200);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
after(() => {
|
||||||
|
server.close();
|
||||||
|
});
|
Reference in a new issue