diff --git a/gulpfile.js b/gulpfile.js index a401e7f326..a18d4ef118 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -189,15 +189,25 @@ gulp.task('bundle.js', function() { // throw new Error(error); // }) //}); +gulp.task('tests', function() { + return gulp.src('ionic/components/*/test/*/**/*.spec.ts') + .pipe(tsc(tscOptions, null, tscReporter)) + .pipe(babel()) + .pipe(rename(function(file) { + file.dirname = file.dirname.replace(path.sep + 'test' + path.sep, path.sep) + })) + .pipe(gulp.dest('dist/tests')) +}) + gulp.task('examples', function() { var buildTest = lazypipe() //.pipe(traceur, traceurOptions) - .pipe(tsc, tscOptions, null, tsc.reporter.nullReporter()) + .pipe(tsc, tscOptions, null, tscReporter) .pipe(babel, exampleBabelOptions) // Get each test folder with gulp.src - return gulp.src('ionic/components/*/test/*/**/*') + return gulp.src(['ionic/components/*/test/*/**/*', '!ionic/components/*/test/*/**/*.spec.ts']) .pipe(cache('examples', { optimizeMemory: true })) .pipe(gulpif(/.ts$/, buildTest())) .on('error', function (err) { @@ -263,7 +273,8 @@ gulp.task('vendor', function() { require('./scripts/snapshot/snapshot.task')(gulp, argv, buildConfig); gulp.task('karma', function() { - return karma.start({ configFile: __dirname + '/scripts/test/karma.conf.js' }) + //return karma.start({ configFile: __dirname + '/scripts/test/karma.conf.js' }) + return karma.start({ configFile: __dirname + '/karma.conf.js' }) }); gulp.task('karma-watch', function() { diff --git a/ionic/components/app/test/sink/sink.spec.ts b/ionic/components/app/test/sink/sink.spec.ts new file mode 100644 index 0000000000..4736d4f930 --- /dev/null +++ b/ionic/components/app/test/sink/sink.spec.ts @@ -0,0 +1,7 @@ +import {Ion} from 'ionic/ion'; + +export function main() { + it('should be true', () => { + expect(true).toBe(true); + }); +} diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000000..c83e60d8bd --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,68 @@ +// Karma configuration +// Generated on Mon Jul 13 2015 15:16:50 GMT-0500 (CDT) + +module.exports = function(config) { + 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: ['jasmine'], + + + // list of files / patterns to load in the browser + files: [ + {pattern: 'dist/js/es5/ionic/**/*.js', included: false}, + {pattern: 'dist/tests/**/*.spec.js', included: true}, + 'test-main.js' + ], + + + // list of files to exclude + exclude: [ + 'ionic/components/*/test/*/**/*' + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + }, + + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress'], + + + // 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: ['Chrome'], + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false + }) +} diff --git a/package.json b/package.json index f5e1245045..2b67697c80 100644 --- a/package.json +++ b/package.json @@ -25,10 +25,12 @@ "karma": "^0.12.31", "karma-chrome-launcher": "^0.1.7", "karma-jasmine": "^0.3.5", + "karma-requirejs": "^0.2.2", "lazypipe": "^0.2.3", "lodash": "^2.4.1", "node-libs-browser": "^0.5.2", "node-uuid": "^1.4.1", + "requirejs": "^2.1.19", "run-sequence": "^1.1.0", "serve-static": "^1.9.2", "source-map-support": "^0.2.10", diff --git a/scripts/test/karma.conf.js b/scripts/test/karma.conf.js index 432c46639e..ae5b8467b3 100644 --- a/scripts/test/karma.conf.js +++ b/scripts/test/karma.conf.js @@ -3,7 +3,7 @@ var buildConfig = require('../build/config'); module.exports = function(config) { config.set({ singleRun: true, - basePath: '../../dist/lib', + basePath: '../..', frameworks: ['jasmine'], diff --git a/test-main.js b/test-main.js new file mode 100644 index 0000000000..8c822774c9 --- /dev/null +++ b/test-main.js @@ -0,0 +1,2 @@ + +__karma__.start();