Skip to content

Instantly share code, notes, and snippets.

@dj1020
Last active August 29, 2015 14:17
Show Gist options
  • Save dj1020/f680aebccb7079e24fd0 to your computer and use it in GitHub Desktop.
Save dj1020/f680aebccb7079e24fd0 to your computer and use it in GitHub Desktop.
Gulpfile.js Example for codeception with notification
var gulp = require('gulp');
var notify = require('gulp-notify');
var codecept = require('gulp-codeception');
var _ = require('lodash');
gulp.task('runtest', function() {
var options = testCodeceptOptions('api', 'categoryProductApiCest');
gulp.src('codeception.yml')
.pipe(codecept('./vendor/bin/codecept', options))
.on('error', notify.onError(testNotification('fail', 'codeception')))
.pipe(notify(testNotification('pass', 'codeception')));
});
function testCodeceptOptions(suite, flags) {
var flags = flags || '';
var options = {
debug: false,
clear: true,
testSuite: suite,
notify: true,
flags: "--colors " + flags
};
return options;
}
function testNotification(status, pluginName, override) {
var options = {
title: (status == 'pass') ? 'Tests Passed' : 'Tests Failed',
message: (status == 'pass') ? '\n\nAll tests have passed!\n\n' : '\n\nOne or more tests failed...\n\n',
icon: __dirname + '/node_modules/gulp-' + pluginName + '/assets/test-' + status + '.png'
};
options = _.merge(options, override);
return options;
}
gulp.task('watch', function () {
gulp.watch(['tests/**/*.php', 'app/**/*.php'], ['runtest']);
});
gulp.task('default', ['runtest', 'watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment