From a126b9abb5fa9e3a10bb62c356a78c402138d698 Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Mon, 13 Jul 2015 17:07:08 -0500 Subject: [PATCH] make tests es6 modules --- gulpfile.js | 20 +++++- ionic/components/app/test/sink/sink.spec.ts | 2 +- karma.conf.js | 68 --------------------- scripts/build/config.js | 41 +++---------- scripts/test/karma.conf.js | 10 +-- scripts/test/test-main.js | 16 +---- test-main.js | 2 - 7 files changed, 32 insertions(+), 127 deletions(-) delete mode 100644 karma.conf.js delete mode 100644 test-main.js diff --git a/gulpfile.js b/gulpfile.js index a18d4ef118..3d9339898f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -123,6 +123,20 @@ var exampleBabelOptions = { } }; +var testBabelOptions = { + optional: ['es7.decorators'], + /*plugins: [ + './transformers/disable-define', + 'angular2-annotations', + 'type-assertion:after' + ],*/ + modules: "system", + moduleIds: true, + getModuleId: function(name) { + return "dist/tests/" + name.split('/test').join(''); + } +}; + var tscOptions = { target: 'ES6', // Don't use the version of typescript that gulp-typescript depends on, we need 1.5 @@ -192,7 +206,7 @@ gulp.task('bundle.js', function() { gulp.task('tests', function() { return gulp.src('ionic/components/*/test/*/**/*.spec.ts') .pipe(tsc(tscOptions, null, tscReporter)) - .pipe(babel()) + .pipe(babel(testBabelOptions)) .pipe(rename(function(file) { file.dirname = file.dirname.replace(path.sep + 'test' + path.sep, path.sep) })) @@ -273,8 +287,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 + '/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 index 4736d4f930..c92f2bf092 100644 --- a/ionic/components/app/test/sink/sink.spec.ts +++ b/ionic/components/app/test/sink/sink.spec.ts @@ -1,6 +1,6 @@ import {Ion} from 'ionic/ion'; -export function main() { +export function run() { it('should be true', () => { expect(true).toBe(true); }); diff --git a/karma.conf.js b/karma.conf.js deleted file mode 100644 index c83e60d8bd..0000000000 --- a/karma.conf.js +++ /dev/null @@ -1,68 +0,0 @@ -// 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/scripts/build/config.js b/scripts/build/config.js index d5d74dd2ec..838a61f8ba 100644 --- a/scripts/build/config.js +++ b/scripts/build/config.js @@ -3,7 +3,7 @@ module.exports = { distLib: 'dist/lib', src: { spec: ['ionic/**/test/*.spec.js'], - js: ['ionic/**/*.js', '!src/**/test/**/*.js'], + js: ['ionic/**/*.js'], // Get all the non-js files and main.js e2e: ['ionic/components/*/test/*/**/*'], @@ -12,40 +12,15 @@ module.exports = { }, scripts: [ - { - from: 'node_modules/gulp-traceur/node_modules/traceur/bin/traceur.js', - to: 'traceur.js', - }, { - from: 'node_modules/es6-module-loader/dist/es6-module-loader.src.js', - to: 'es6-module-loader.src.js' - }, { - from: 'node_modules/systemjs/dist/system.src.js', - to: 'system.src.js' - }, { - from: 'scripts/e2e/system-init.js', - to: 'system-init.js' - }, { - from: 'node_modules/angular2/node_modules/zone.js/zone.js', - to: 'zone.js' - }, { - from: 'node_modules/angular2/node_modules/zone.js/long-stack-trace-zone.js', - to: 'long-stack-trace-zone.js' - }, - 'angular2.js', - 'angular2-di.js', - 'ionic2.js', -// 'https://cdn.firebase.com/js/client/2.2.4/firebase.js' -// 'https://cdn.firebase.com/js/client/2.2.4/firebase-debug.js' + 'scripts/resources/traceur-runtime.js', + { pattern: 'jspm_packages/es6-module-loader.js', included: false }, + 'jspm_packages/system.src.js', + 'config.js', + 'scripts/resources/angular2.dev.js', + 'dist/js/ionic.bundle.js', + 'dist/vendor/web-animations-js/web-animations.min.js' ], - traceurOptions: { - sourceMaps: true, - annotations: true, - types: true, - memberVariables: true, - modules: 'instantiate', - }, - protractorPort: 8876, autoprefixer: { diff --git a/scripts/test/karma.conf.js b/scripts/test/karma.conf.js index ae5b8467b3..52f1c9c510 100644 --- a/scripts/test/karma.conf.js +++ b/scripts/test/karma.conf.js @@ -2,14 +2,15 @@ var buildConfig = require('../build/config'); module.exports = function(config) { config.set({ - singleRun: true, - basePath: '../..', + //singleRun: true, + basePath: '../../', frameworks: ['jasmine'], files: buildConfig.scripts.concat([ - {pattern: 'ionic2/**/*.js', included: false}, - '../../scripts/test/test-main.js', + 'dist/js/es5/ionic/**/*.js', + 'dist/tests/**/*.spec.js', + 'scripts/test/test-main.js' ]), exclude: buildConfig.src.e2e, @@ -17,7 +18,6 @@ module.exports = function(config) { logLevel: 'warn', preprocessors: { - 'modules/**/*.js': ['traceur'] }, browsers: ['Chrome'], diff --git a/scripts/test/test-main.js b/scripts/test/test-main.js index 1bfbdbb7b4..30cdef58ce 100644 --- a/scripts/test/test-main.js +++ b/scripts/test/test-main.js @@ -4,26 +4,12 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 50; // we will call `__karma__.start()` later, once all the specs are loaded. __karma__.loaded = function() {}; -System.config({ - baseURL: 'http://localhost:9876/base', - traceurOptions: { - 'sourceMaps': true, - 'annotations': true, - 'types': true, - 'script': false, - 'memberVariables': true, - 'modules': 'instantiate' - }, - map: { - 'rx/dist/rx.all': 'rx.all', - } -}) - Promise.all( Object.keys(window.__karma__.files) // All files served by Karma. .filter(onlySpecFiles) .map(window.file2moduleName) // Normalize paths to module names. .map(function(path) { + debugger; return System.import(path).then(function(module) { if (module.hasOwnProperty('run')) { module.run(); diff --git a/test-main.js b/test-main.js deleted file mode 100644 index 8c822774c9..0000000000 --- a/test-main.js +++ /dev/null @@ -1,2 +0,0 @@ - -__karma__.start();