diff --git a/.travis.yml b/.travis.yml index 80efb7c9ae..937532a592 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,9 @@ language: node_js node_js: - 4.0 +- 6.0 +before_install: +- npm install -g mocha install: - npm install script: diff --git a/gulp/tasks.js b/gulp/tasks.js index f87a146d57..bab78463d9 100644 --- a/gulp/tasks.js +++ b/gulp/tasks.js @@ -6,6 +6,7 @@ var gulp = require('gulp') var gutil = require('gulp-util') +var mocha = require('gulp-mocha') var runSequence = require('run-sequence') gulp.task('default', function (done) { @@ -36,6 +37,13 @@ gulp.task('watch', function (done) { }) gulp.task('test', function (done) { - gutil.log('Test that the app runs') - done() + runSequence('generate-assets', + 'mocha', + done) +}) + +gulp.task('mocha', function () { + return gulp.src(['test/**/*.js'], { read: false }) + .pipe(mocha({ reporter: 'spec' })) + .on('error', gutil.log) }) diff --git a/package.json b/package.json index 905c5800f9..11175a7082 100644 --- a/package.json +++ b/package.json @@ -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", @@ -42,5 +42,9 @@ "serve-favicon": "2.3.0", "standard": "^7.1.2", "sync-request": "^3.0.1" + }, + "devDependencies": { + "gulp-mocha": "^3.0.1", + "supertest": "^2.0.0" } } diff --git a/server.js b/server.js index 9f4176c1aa..010334a5b9 100644 --- a/server.js +++ b/server.js @@ -206,3 +206,5 @@ utils.findAvailablePort(app, function (port) { }) } }) + +module.exports = app diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 0000000000..4a52320178 --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1 @@ +--recursive diff --git a/test/spec/sanity-checks.js b/test/spec/sanity-checks.js new file mode 100644 index 0000000000..d377806355 --- /dev/null +++ b/test/spec/sanity-checks.js @@ -0,0 +1,32 @@ +/* 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) { + 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) + }) +})