Skip to content

Commit

Permalink
feat(ava): initial project setup for ava test runner
Browse files Browse the repository at this point in the history
project setup for ava test runner includes the use of `gulp-ava` to integrate with a gulp task,

updating the package.json to be able to fire up gulp with `--harmony` flag to support code use of

async/await and other ES6/7 features. To currently support the existing tests in MEAN.JS 1 code the

test asset has been added as *.test.js files (and not *.tests.js in plural) which also complies with

Ava globbing
  • Loading branch information
lirantal committed Dec 31, 2016
1 parent 02608a2 commit 0f4da27
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 13 deletions.
1 change: 1 addition & 0 deletions server/config/assets/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
config: ['modules/*/server/config/*.js'],
policies: 'modules/*/server/policies/*.js',
tests: ['modules/*/tests/server/**/*.js'],
test: ['modules/*/test/server/**/*.js'],
views: ['modules/*/server/views/*.html']
}
};
24 changes: 24 additions & 0 deletions server/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,30 @@ gulp.task('test', function (done) {
runSequence('env:test', 'test:server', done);
});

gulp.task('server:bootstrap', function(done) {
const app = require('./config/lib/app');
app.start().then(function() {
done();
});
});

gulp.task('ava:test:integration', function() {
gulp.src(defaultAssets.server.test)
// gulp-ava needs filepaths so you can't have any plugins before it
.pipe(plugins.ava({verbose: true}))
.on('error', function(err) {
console.log(err.message);
process.exit(1);
})
.on('end', function() {
process.exit(0);
});
});

gulp.task('test:integration', function(done) {
runSequence('env:test', 'server:bootstrap', 'ava:test:integration', done);
});

gulp.task('test:server', function (done) {
runSequence('env:test', 'lint', ['copyLocalEnvConfig', 'makeUploadsDir'], 'mocha', done);
});
Expand Down
4 changes: 3 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
"start": "gulp",
"start:prod": "gulp prod",
"start:debug": "gulp debug",
"gulp": "gulp",
"gulp": "node --harmony node_modules/.bin/gulp",
"test": "gulp test",
"ava": "NODE_ENV=development node --harmony server.js & sleep 5 && ava",
"test:server": "gulp test:server",
"test:server:watch": "gulp test:server:watch",
"test:coverage": "gulp test:coverage",
Expand All @@ -45,6 +46,7 @@
"file-stream-rotator": "~0.0.6",
"generate-password": "~1.2.0",
"glob": "~7.1.0",
"gulp-ava": "^0.15.0",
"helmet": "~2.3.0",
"jasmine-core": "~2.5.0",
"lodash": "~4.16.2",
Expand Down
12 changes: 0 additions & 12 deletions server/test.js

This file was deleted.

16 changes: 16 additions & 0 deletions server/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,12 @@ d@^0.1.1, d@~0.1.1:
dependencies:
es5-ext "~0.10.2"

dargs@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/dargs/-/dargs-4.1.0.tgz#03a9dbb4b5c2f139bf14ae53f0b8a2a6a86f4e17"
dependencies:
number-is-nan "^1.0.0"

dashdash@^1.12.0:
version "1.14.1"
resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0"
Expand Down Expand Up @@ -2745,6 +2751,16 @@ growl@1.9.2:
version "1.9.2"
resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f"

gulp-ava@^0.15.0:
version "0.15.0"
resolved "https://registry.yarnpkg.com/gulp-ava/-/gulp-ava-0.15.0.tgz#8dc59e4a95d603a2ee1dfaad2993ea8d6cb510c2"
dependencies:
ava "^0.17.0"
dargs "^4.1.0"
gulp-util "^3.0.6"
resolve-cwd "^1.0.0"
through2 "^2.0.0"

gulp-concat@~2.6.0:
version "2.6.1"
resolved "https://registry.yarnpkg.com/gulp-concat/-/gulp-concat-2.6.1.tgz#633d16c95d88504628ad02665663cee5a4793353"
Expand Down

0 comments on commit 0f4da27

Please sign in to comment.