Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting up a very simple test suite to check the server and build tasks run across nodejs 4, 5 & 6 #292

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
language: node_js
node_js:
- 4.0
- "4"
- "5"
- "6"
before_install:
- npm install -g grunt-cli
- npm install -g mocha
install:
- npm install
script:
- "./node_modules/grunt-cli/bin/grunt test"
- npm test
after_success:
- "./create-release-tag.sh"
Expand Down
8 changes: 0 additions & 8 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,4 @@ module.exports = function (grunt) {
'generate-assets',
'concurrent:target'
])

grunt.registerTask(
'test',
'default',
function () {
grunt.log.writeln('Test that the app runs')
}
)
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"scripts": {
"start": "node start.js",
"lint": "standard",
"test": "npm run lint"
"test": "mocha && npm run lint"
},
"dependencies": {
"basic-auth": "^1.0.3",
Expand Down Expand Up @@ -40,5 +40,8 @@
"serve-favicon": "2.3.0",
"standard": "^7.1.2",
"sync-request": "^3.0.1"
},
"devDependencies": {
"supertest": "^2.0.0"
}
}
2 changes: 2 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,5 @@ utils.findAvailablePort(app, function (port) {
})
}
})

module.exports = app
1 change: 1 addition & 0 deletions test/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--recursive
34 changes: 34 additions & 0 deletions test/spec/sanity-checks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* global describe, it, before */
var request = require('supertest')
var assert = require('assert')
var path = require('path')
var fs = require('fs')

/**
* Basic sanity checks on the dev server
*/
describe('The prototype kit', function () {
var app

before(function (done) {
require('grunt').tasks(['generate-assets'], {}, function () {
app = require('../../server')
done()
})
})

it('should generate assets into the /public folder', function () {
assert.doesNotThrow(function () {
fs.accessSync(path.resolve(__dirname, '../../public/javascripts/application.js'))
fs.accessSync(path.resolve(__dirname, '../../public/images/favicon.ico'))
fs.accessSync(path.resolve(__dirname, '../../public/stylesheets/application.css'))
})
})

it('should send with a well formed response for the index page', function (done) {
request(app)
.get('/')
.expect('Content-Type', /text\/html/)
.expect(200, done)
})
})