make tests work

This commit is contained in:
Andrew
2015-03-29 10:53:19 -06:00
parent 91ff27a675
commit bedbe8b489
9 changed files with 31 additions and 173 deletions

View File

@@ -5,7 +5,7 @@ module.exports = {
spec: ['src/**/test/*.spec.js'],
js: ['src/**/*.js', '!src/**/test/**/*.js'],
e2eTest: ['src/components/*/test/*/'],
e2e: ['src/components/*/test/**/*'],
e2e: ['src/components/*/test/*/**/*'],
html: 'src/**/*.html',
scss: 'src/components/**/*.scss',
},

View File

@@ -3,25 +3,16 @@ var buildConfig = require('../build/config');
module.exports = function(config) {
config.set({
singleRun: true,
basePath: '../..',
basePath: '../../dist/lib',
frameworks: ['jasmine'],
files: [
'node_modules/systemjs/dist/system.js',
'node_modules/es6-module-loader/dist/es6-module-loader.js',
'node_modules/traceur-runtime/index.js',
'node_modules/zone.js/zone.js',
'node_modules/zone.js/long-stack-trace-zone.js',
'dist/lib/angular2.js',
'jspm-config.js',
'scripts/test/test-main.js',
{pattern: 'src/**/*.spec.js', included: false},
],
files: buildConfig.scripts.concat([
{pattern: 'ionic2/**/*.js', included: false},
'../../scripts/test/test-main.js',
]),
exclude: [
'src/**/examples/**'
],
exclude: buildConfig.src.e2e,
logLevel: 'warn',

View File

@@ -1,20 +1,23 @@
// Use "register" extension from systemjs.
// That's what Traceur outputs: `System.register()`.
register(System);
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50;
// Cancel Karma's synchronous start,
// we will call `__karma__.start()` later, once all the specs are loaded.
__karma__.loaded = function() {};
System.baseURL = 'http://localhost:9876/base/';
// So that we can import packages like `core/foo`, instead of `core/src/foo`.
// System.paths = {
// '*': './*.js',
// 'transpiler/*': '../tools/transpiler/*.js'
// }
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.
@@ -22,10 +25,10 @@ Promise.all(
.map(window.file2moduleName) // Normalize paths to module names.
.map(function(path) {
return System.import(path).then(function(module) {
if (module.hasOwnProperty('main')) {
module.main();
if (module.hasOwnProperty('run')) {
module.run();
} else {
throw new Error('Module ' + path + ' does not implement main() method.');
throw new Error('Module ' + path + ' does not implement run() method.');
}
});
}))
@@ -41,12 +44,12 @@ function onlySpecFiles(path) {
}
function file2moduleName(filePath) {
return filePath.replace(/\\/g, '/')
.replace(/^.*?\/dist\//, '')
.replace(/^.*?base\//, '')
// module name should be relative to `modules` and `tools` folder
// .replace(/.*\/modules\//, '')
// .replace(/.*\/tools\//, '')
// module name should not include `lib`, `web` folders
// module name should not have a suffix
// .split('.').pop().join('');
.replace(/\.\w*$/, '');
.replace(/\.js$/, '');
}