mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 19:57:22 +08:00
make tests es6 modules
This commit is contained in:
20
gulpfile.js
20
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() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {Ion} from 'ionic/ion';
|
||||
|
||||
export function main() {
|
||||
export function run() {
|
||||
it('should be true', () => {
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
|
@ -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
|
||||
})
|
||||
}
|
@ -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: {
|
||||
|
@ -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'],
|
||||
|
@ -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();
|
||||
|
@ -1,2 +0,0 @@
|
||||
|
||||
__karma__.start();
|
Reference in New Issue
Block a user