chore(build): Karma watches broccoli output.
This is a prerequisite for switching to TypeScript. We need to remove the Traceur preprocessor from Karma, so we have the build specified in a single place (broccoli tree def'n).
This commit is contained in:
parent
09f8d8f7ba
commit
511e832ee2
35
gulpfile.js
35
gulpfile.js
|
@ -24,7 +24,7 @@ var jsserve = require('./tools/build/jsserve');
|
|||
var pubserve = require('./tools/build/pubserve');
|
||||
var rundartpackage = require('./tools/build/rundartpackage');
|
||||
var file2moduleName = require('./tools/build/file2modulename');
|
||||
var karma = require('karma').server;
|
||||
var karma = require('karma');
|
||||
var minimist = require('minimist');
|
||||
var runServerDartTests = require('./tools/build/run_server_dart_tests');
|
||||
var sourcemaps = require('gulp-sourcemaps');
|
||||
|
@ -320,18 +320,41 @@ function getBrowsersFromCLI() {
|
|||
var args = minimist(process.argv.slice(2));
|
||||
return [args.browsers?args.browsers:'DartiumWithWebPlatform']
|
||||
}
|
||||
gulp.task('test.unit.js', function (done) {
|
||||
karma.start({configFile: __dirname + '/karma-js.conf.js'}, done);
|
||||
|
||||
gulp.task('test.unit.js', ['build/clean.js'], function (neverDone) {
|
||||
|
||||
function buildAndTest() {
|
||||
runSequence(
|
||||
'broccoli.js.dev',
|
||||
'test.unit.dev/karma-run'
|
||||
);
|
||||
}
|
||||
|
||||
karma.server.start({configFile: __dirname + '/karma-js.conf.js'});
|
||||
buildAndTest();
|
||||
|
||||
gulp.watch('modules/**', function() {
|
||||
console.log('args', arguments);
|
||||
buildAndTest();
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('test.unit.dev/karma-run', function(done) {
|
||||
karma.runner.run({configFile: __dirname + '/karma-js.conf.js'}, done);
|
||||
});
|
||||
|
||||
|
||||
gulp.task('test.unit.dart', function (done) {
|
||||
karma.start({configFile: __dirname + '/karma-dart.conf.js'}, done);
|
||||
karma.server.start({configFile: __dirname + '/karma-dart.conf.js'}, done);
|
||||
});
|
||||
|
||||
gulp.task('test.unit.js/ci', function (done) {
|
||||
karma.start({configFile: __dirname + '/karma-js.conf.js',
|
||||
karma.server.start({configFile: __dirname + '/karma-js.conf.js',
|
||||
singleRun: true, reporters: ['dots'], browsers: getBrowsersFromCLI()}, done);
|
||||
});
|
||||
|
||||
gulp.task('test.unit.dart/ci', function (done) {
|
||||
karma.start({configFile: __dirname + '/karma-dart.conf.js',
|
||||
karma.server.start({configFile: __dirname + '/karma-dart.conf.js',
|
||||
singleRun: true, reporters: ['dots'], browsers: getBrowsersFromCLI()}, done);
|
||||
});
|
||||
|
||||
|
|
|
@ -10,8 +10,7 @@ module.exports = function(config) {
|
|||
files: [
|
||||
// Sources and specs.
|
||||
// Loaded through the es6-module-loader, in `test-main.js`.
|
||||
{pattern: 'modules/**', included: false},
|
||||
{pattern: 'tools/transpiler/spec/**', included: false},
|
||||
{pattern: 'dist/js/dev/es5/**', included: false, watched: false},
|
||||
|
||||
'node_modules/traceur/bin/traceur-runtime.js',
|
||||
'node_modules/es6-module-loader/dist/es6-module-loader-sans-promises.src.js',
|
||||
|
@ -28,34 +27,9 @@ module.exports = function(config) {
|
|||
],
|
||||
|
||||
exclude: [
|
||||
'modules/**/e2e_test/**'
|
||||
'dist/js/dev/es5/**/e2e_test/**',
|
||||
],
|
||||
|
||||
preprocessors: {
|
||||
'modules/**/*.js': ['traceur'],
|
||||
'modules/**/*.es6': ['traceur'],
|
||||
'tools/transpiler/spec/**/*.js': ['traceur'],
|
||||
'tools/transpiler/spec/**/*.es6': ['traceur'],
|
||||
},
|
||||
|
||||
traceurPreprocessor: {
|
||||
options: {
|
||||
outputLanguage: 'es5',
|
||||
sourceMaps: true,
|
||||
script: false,
|
||||
memberVariables: true,
|
||||
modules: 'instantiate',
|
||||
types: true,
|
||||
typeAssertions: true,
|
||||
typeAssertionModule: 'rtts_assert/rtts_assert',
|
||||
annotations: true
|
||||
},
|
||||
resolveModuleName: file2moduleName,
|
||||
transformPath: function(fileName) {
|
||||
return fileName.replace(/\.es6$/, '.js');
|
||||
}
|
||||
},
|
||||
|
||||
customLaunchers: {
|
||||
DartiumWithWebPlatform: {
|
||||
base: 'Dartium',
|
||||
|
@ -68,6 +42,4 @@ module.exports = function(config) {
|
|||
|
||||
port: 9876
|
||||
});
|
||||
|
||||
config.plugins.push(require('./tools/transpiler/karma-traceur-preprocessor'));
|
||||
};
|
||||
|
|
11
test-main.js
11
test-main.js
|
@ -9,15 +9,16 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 100;
|
|||
// we will call `__karma__.start()` later, once all the specs are loaded.
|
||||
__karma__.loaded = function() {};
|
||||
|
||||
|
||||
System.baseURL = '/base/modules/';
|
||||
System.baseURL = '/base/';
|
||||
|
||||
// So that we can import packages like `core/foo`, instead of `core/src/foo`.
|
||||
System.paths = {
|
||||
'*': './*.js',
|
||||
'transpiler/*': '../tools/transpiler/*.js',
|
||||
'rx/*': '../node_modules/rx/*.js'
|
||||
}
|
||||
'benchpress/*': 'dist/js/dev/es5/benchpress/*.js',
|
||||
'angular2/*': 'dist/js/dev/es5/angular2/*.js',
|
||||
'rtts_assert/*': 'dist/js/dev/es5/rtts_assert/*.js',
|
||||
'rx/*': 'node_modules/rx/*.js'
|
||||
};
|
||||
|
||||
// Import all the specs, execute their `main()` method and kick off Karma (Jasmine).
|
||||
System.import('angular2/src/dom/browser_adapter').then(function(browser_adapter) {
|
||||
|
|
|
@ -3,6 +3,8 @@ function file2moduleName(filePath) {
|
|||
// module name should be relative to `modules` and `tools` folder
|
||||
.replace(/.*\/modules\//, '')
|
||||
.replace(/.*\/tools\//, '')
|
||||
// and 'dist' folder
|
||||
.replace(/.*\/dist\/js\/dev\/es5\//, '')
|
||||
// module name should not include `lib`, `web` folders
|
||||
// as they are wrapper packages for dart
|
||||
.replace(/\/web\//, '/')
|
||||
|
|
Loading…
Reference in New Issue