diff --git a/file2modulename.js b/file2modulename.js
index fff3c8e0db..784745cd43 100644
--- a/file2modulename.js
+++ b/file2modulename.js
@@ -9,10 +9,9 @@ function file2moduleName(filePath) {
// module name should not include `src`, `test`, `lib`
.replace(/\/src\//, '/')
.replace(/\/lib\//, '/')
- .replace(/\/test\//, '/')
// module name should not have a suffix
.replace(/\.\w*$/, '');
}
if (typeof module !== 'undefined') {
module.exports = file2moduleName;
-}
\ No newline at end of file
+}
diff --git a/karma-js.conf.js b/karma-js.conf.js
index 8f1ff18471..57e9b883e8 100644
--- a/karma-js.conf.js
+++ b/karma-js.conf.js
@@ -8,12 +8,15 @@ module.exports = function(config) {
frameworks: ['jasmine'],
files: [
+ // Sources and specs.
+ // Loaded through the es6-module-loader, in `test-main.js`.
+ {pattern: 'modules/**', included: false},
+ {pattern: 'tools/transpiler/**', included: false},
+
'node_modules/traceur/bin/traceur-runtime.js',
- 'modules/**/test_lib/**/*.es6',
- 'modules/**/*.js',
- 'modules/**/*.es6',
- 'tools/transpiler/spec/**/*.js',
- 'tools/transpiler/spec/**/*.es6',
+ 'node_modules/es6-module-loader/dist/es6-module-loader-sans-promises.src.js',
+ 'node_modules/systemjs/lib/extension-register.js',
+
'file2modulename.js',
'test-main.js'
],
@@ -29,7 +32,7 @@ module.exports = function(config) {
options: {
outputLanguage: 'es5',
script: false,
- modules: 'register',
+ modules: 'instantiate',
types: true,
typeAssertions: true,
typeAssertionModule: 'rtts_assert/rtts_assert',
@@ -37,7 +40,7 @@ module.exports = function(config) {
},
resolveModuleName: file2moduleName,
transformPath: function(fileName) {
- return fileName.replace('.es6', '');
+ return fileName.replace(/\.es6$/, '.js');
}
},
diff --git a/modules/rtts_assert/test/rtts_assert_spec.es6 b/modules/rtts_assert/test/rtts_assert_spec.es6
index 368f380e2c..8e93538961 100644
--- a/modules/rtts_assert/test/rtts_assert_spec.es6
+++ b/modules/rtts_assert/test/rtts_assert_spec.es6
@@ -13,6 +13,7 @@
import {assert} from 'rtts_assert/rtts_assert';
+export function main() {
// ## Basic Type Check
// By default, `instanceof` is used to check the type.
@@ -375,3 +376,5 @@ describe('Traceur', function() {
//
// This documentation was generated from [assert.spec.js](https://github.com/vojtajina/assert/blob/master/test/assert.spec.js) using [Docco](http://jashkenas.github.io/docco/).
//
+
+}
diff --git a/package.json b/package.json
index 4fe1b0df33..66826d5086 100644
--- a/package.json
+++ b/package.json
@@ -8,6 +8,8 @@
"author": "Tobias Bosch ",
"license": "MIT",
"dependencies": {
+ "es6-module-loader": "^0.9.2",
+ "systemjs": "^0.9.1",
"gulp": "^3.8.8",
"gulp-rename": "^1.2.0",
"gulp-watch": "^1.0.3",
diff --git a/test-main.js b/test-main.js
index cc7a128480..303311dfb5 100644
--- a/test-main.js
+++ b/test-main.js
@@ -1,11 +1,60 @@
-var TEST_REGEXP = /_spec.*/;
+// Use "register" extension from systemjs.
+// That's what Traceur outputs: `System.register()`.
+register(System);
-Object.keys(window.__karma__.files).forEach(function(path) {
- if (TEST_REGEXP.test(path)) {
- var moduleName = window.file2moduleName(path);
- var mod = System.get(moduleName);
- if (mod && mod.main) {
- mod.main();
- }
- }
+
+// Cancel Karma's synchronous start,
+// we will call `__karma__.start()` later, once all the specs are loaded.
+__karma__.loaded = function() {};
+
+
+System.baseURL = '/base/modules/';
+
+// So that we can import packages like `core/foo`, instead of `core/src/foo`.
+System.paths = {
+ 'core/*': './core/src/*.js',
+ 'core/test/*': './core/test/*.js',
+
+ 'change_detection/*': './change_detection/src/*.js',
+ 'change_detection/test/*': './change_detection/test/*.js',
+
+ 'facade/*': './facade/src/*.js',
+ 'facade/test/*': './facade/test/*.js',
+
+ 'di/*': './di/src/*.js',
+ 'di/test/*': './di/test/*.js',
+
+ 'rtts_assert/*': './rtts_assert/src/*.js',
+ 'rtts_assert/test/*': './rtts_assert/test/*.js',
+
+ 'test_lib/*': './test_lib/src/*.js',
+ 'test_lib/test/*': './test_lib/test/*.js',
+
+ 'transpiler/*': '../tools/transpiler/*.js'
+}
+
+
+// Import all the specs, execute their `main()` method and kick off Karma (Jasmine).
+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) {
+ return System.import(path).then(function(module) {
+ if (module.hasOwnProperty('main')) {
+ module.main()
+ } else {
+ throw new Error('Module ' + path + ' does not implement main() method.');
+ }
+ });
+ })).then(function() {
+ __karma__.start();
+}, function(error) {
+ console.error(error.stack || error)
+ __karma__.start();
});
+
+
+function onlySpecFiles(path) {
+ return /_spec\.js$/.test(path);
+}
diff --git a/tools/transpiler/spec/a-0-subfolder/library_spec.js b/tools/transpiler/spec/a-0-subfolder/library_spec.js
index c155700ced..f0ed26b348 100644
--- a/tools/transpiler/spec/a-0-subfolder/library_spec.js
+++ b/tools/transpiler/spec/a-0-subfolder/library_spec.js
@@ -1,3 +1 @@
-function main() {
- assert(true);
-}
\ No newline at end of file
+export function main() {}