Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mAAdhaTTah committed Jan 15, 2017
1 parent 54c5736 commit 088c42c
Show file tree
Hide file tree
Showing 4 changed files with 1,177 additions and 62 deletions.
58 changes: 58 additions & 0 deletions gulpfile.babel.js/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Karma configuration
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = 'test';
}

module.exports = function (config) {
const tests = './client/**/__tests__/*.spec.js';

config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '../',

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['ava'],

// list of files / patterns to load in the browser
files: [
tests
],

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
// reporters: ['spec'],

// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_DEBUG,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity,

// Ensure Karma doesn't use an iFrame.
client: {
useIframe: false
}
});
};
17 changes: 13 additions & 4 deletions gulpfile.babel.js/test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
const gulp = require('gulp');
const ava = require('gulp-ava');
const gutil = require('gulp-util');
const { Server } = require('karma');

gulp.task('test', ['test:unit']);

gulp.task('test:unit', () => {
gulp.task('test:unit', done => {
process.env.BABEL_ENV = 'test';

return gulp.src('../client/**/__tests__/*.spec.js')
.pipe(ava({ verbose: true }));
const server = new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, () => {
gutil.log('Tests complete');

done();
});

server.start();
});
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@
"gulp-wp-pot": "1.0.1",
"handlebars": "^4.0.5",
"handlebars-loader": "^1.1.4",
"karma": "^1.4.0",
"karma-ava": "git+ssh://git@github.com/avajs/karma-ava.git",
"karma-phantomjs-launcher": "^1.0.2",
"karma-spec-reporter": "0.0.26",
"node-notifier": "^4.6.1",
"phantomjs-prebuilt": "^2.1.14",
"sass-loader": "^4.0.2",
"style-loader": "^0.13.1",
"webpack": "2.2.0-rc.3",
Expand Down
Loading

0 comments on commit 088c42c

Please sign in to comment.