chore: karma with JS, Dart
Note: karma with dart is still not working because of how `karma-dart` loads `package:…` dependencies. Usage: ``` karma start karma-js.conf.js karma start karma-dart.conf.js ``` Make sure to set `DARTIUM_BIN` env variable. Refactors `js2dart`: - live outside of the traceur module (`tools/js2dart/index.js`) so it can be reused by gulp and karma - automatically build the sources in memory, so that `js2dart` can be used without running `gulp build` first - provide a way to specify the moduleName of a compilation run independently of the input filename. This helps error messages and source maps (not yet enabled) to report the correct file name Changes project setup: - add module `test_lib` that contains the primitives for tests (e.g. `describe`, `it`, …) - clean up some sources that had errors in them - module names in transpiled js and dart files don’t contain `lib`, `test` nor `src` any more (e.g. `di/di`).
This commit is contained in:
61
karma-dart.conf.js
Normal file
61
karma-dart.conf.js
Normal file
@ -0,0 +1,61 @@
|
||||
// Karma configuration
|
||||
// Generated on Thu Sep 25 2014 11:52:02 GMT-0700 (PDT)
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
|
||||
frameworks: ['dart-unittest'],
|
||||
|
||||
files: [
|
||||
{pattern: 'packages/**/*.dart', included: false},
|
||||
{pattern: 'modules/*/src/**/*.js', included: false},
|
||||
{pattern: 'modules/*/test/**/*.js', included: true},
|
||||
{pattern: 'modules/**/*.dart', included: false},
|
||||
'packages/browser/dart.js'
|
||||
],
|
||||
|
||||
karmaDartImports: {
|
||||
guinness: 'package:guinness/guinness_html.dart'
|
||||
},
|
||||
|
||||
preprocessors: {
|
||||
'modules/**/*.js': ['traceur']
|
||||
},
|
||||
customFileHandlers: [{
|
||||
urlRegex: /.*\/packages\/.*$/,
|
||||
handler: function(request, response, fa, fb, basePath) {
|
||||
var url = request.url;
|
||||
var path = url.indexOf('?') > -1 ? url.substring(0, url.indexOf('?')) : url;
|
||||
var contets = fs.readFileSync(basePath + path);
|
||||
response.writeHead(200);
|
||||
response.end(contets);
|
||||
}
|
||||
}],
|
||||
traceurPreprocessor: {
|
||||
options: {
|
||||
outputLanguage: 'dart',
|
||||
script: false,
|
||||
modules: 'register',
|
||||
types: true,
|
||||
// typeAssertions: true,
|
||||
// typeAssertionModule: 'assert',
|
||||
annotations: true
|
||||
},
|
||||
resolveModuleName: function(fileName) {
|
||||
var moduleName = fileName
|
||||
.replace(/.*\/modules\//, '')
|
||||
.replace(/\/src\//, '/')
|
||||
.replace(/\/test\//, '/');
|
||||
return moduleName;
|
||||
},
|
||||
transformPath: function(fileName) {
|
||||
return fileName.replace('.js', '.dart');
|
||||
}
|
||||
},
|
||||
|
||||
browsers: ['Dartium']
|
||||
});
|
||||
|
||||
|
||||
config.plugins.push(require('./tools/js2dart/karma-traceur-preprocessor'));
|
||||
};
|
Reference in New Issue
Block a user