diff --git a/karma.conf.js b/karma.conf.js index 44e6ed9..d481e8b 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -4,6 +4,7 @@ var path = require('path'); var conf = require('./gulp/conf'); + var _ = require('lodash'); var wiredep = require('wiredep'); @@ -17,10 +18,11 @@ function listFiles() { devDependencies: true }); - var patterns = wiredep(wiredepOptions).js + var patterns = [].concat(wiredep(wiredepOptions).js) .concat([ - path.join(conf.paths.src, 'noosfero.js') - ,path.join(conf.paths.src, 'noosfero-testing.js'), + //path.join(conf.paths.src, 'common.js'), + //, path.join(conf.paths.src, 'index.ts') + path.join(conf.paths.src, 'test.js') // path.join(conf.paths.src, '/app/**/*.module.js'), // path.join(conf.paths.src, '/app/**/*.js'), // path.join(conf.paths.src, '/**/*.spec.js'), @@ -41,7 +43,7 @@ function listFiles() { watched: false }); files.push({ - pattern: path.join(conf.paths.src, '/*.map'), + pattern: path.join(conf.paths.src, '/test.js.map'), included: false, served: true }); @@ -68,61 +70,34 @@ module.exports = function (config) { }, - frameworks: ['jasmine'],//, 'angular-filesort'], + frameworks: ['jasmine', 'phantomjs-shim'],//, 'angular-filesort'], angularFilesort: { whitelist: [path.join(conf.paths.src, '/**/!(*.html|*.spec|*.mock).js')] }, - browsers: ['Chrome'], - - webpack: _.merge({}, webpackConfig, { - externals: { - encapsulatedWindow: 'Object.create(window)' - - }, - resolve: { - alias : { - angular: "angular/angular.js" - } - }, - module: { - loaders: [ - { - test: /angular\.js$/, - loaders:[ - 'imports?window=encapsulatedWindow', - 'exports?window.angular' - ], - include: [new RegExp(__dirname + '/bower_components/angular/')] - } - ], - postLoaders: [ - { - test: /src\/noosfero.js/, - exclude: [ - /node_modules\//, - /bower_components\//, - /src\/noosfero-testing.js/ - ], - loader: 'istanbul-instrumenter' - } - - - ] - } + browsers: ['PhantomJS'], + + webpack2: _.merge({ + + }, webpackConfig, { + /*devtool: 'cheap-module-source-map'*/ }), webpackServer: { quite: true }, plugins: [ + require('karma-webpack'), 'karma-chrome-launcher', 'karma-phantomjs-launcher', 'karma-angular-filesort', 'karma-webpack', + 'karma-phantomjs-shim', 'karma-coverage', 'karma-jasmine', - 'karma-ng-html2js-preprocessor' + 'karma-spec-reporter', + 'karma-ng-html2js-preprocessor', + 'karma-sourcemap-loader' ], coverageReporter: { @@ -130,7 +105,7 @@ module.exports = function (config) { dir: 'coverage/' }, - reporters: ['dots', "coverage"], + reporters: ['spec', "coverage"], proxies: { '/assets/': path.join('/base/', conf.paths.src, '/assets/') @@ -141,9 +116,11 @@ module.exports = function (config) { // The coverage preprocessor is added in gulp/unit-test.js only for single tests // It was not possible to do it there because karma doesn't let us now if we are // running a single test or not - configuration.preprocessors = { - 'src/**/*.[sS]pec.ts': ['webpack'] - }; + configuration.preprocessors = {} + // 'src/**/*.ts': ['sourcemap'], + // 'src/**/*.js': ['sourcemap'], + // 'src/**/*.[sS]pec.ts': ['sourcemap'] + // }; pathSrcHtml.forEach(function (path) { configuration.preprocessors[path] = ['ng-html2js']; diff --git a/package.json b/package.json index 24b0609..280c6cc 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "browser-sync-spa": "~1.0.3", "chalk": "~1.1.1", "concurrently": "^2.0.0", + "core-js": "^2.1.3", "del": "~2.0.2", "eslint-plugin-angular": "~0.12.0", "estraverse": "~4.1.0", @@ -52,11 +53,15 @@ "karma-jasmine": "~0.3.6", "karma-ng-html2js-preprocessor": "~0.2.0", "karma-phantomjs-launcher": "~0.2.1", + "karma-phantomjs-shim": "^1.2.0", + "karma-sourcemap-loader": "^0.3.7", + "karma-spec-reporter": "0.0.24", "karma-webpack": "^1.7.0", "lodash": "~3.10.1", "main-bower-files": "~2.9.0", "ng-forward": "0.0.1-alpha.12", "phantomjs": "~1.9.18", + "phantomjs-polyfill": "0.0.2", "reflect-metadata": "^0.1.3", "ts-loader": "^0.8.1", "typescript": "^1.8.2", diff --git a/src/app/components/noosfero-articles/article/article.directive.spec.ts b/src/app/components/noosfero-articles/article/article.directive.spec.ts index d688368..6c2da04 100644 --- a/src/app/components/noosfero-articles/article/article.directive.spec.ts +++ b/src/app/components/noosfero-articles/article/article.directive.spec.ts @@ -1,16 +1,16 @@ -let oldDefine = Object.defineProperties; - -Object.defineProperties = function(object, properties){ - let filteredProps = {}; - let currentProperties = Object.getOwnPropertyNames(object); - for (let i = 0; i < currentProperties.length; i++) { - let prop = currentProperties[i]; - if(currentProperties.indexOf(prop) < 0){ - filteredProps[prop] = properties[prop]; - } - } - oldDefine(object, filteredProps); -}; +// let oldDefine = Object.defineProperties; +// +// Object.defineProperties = function(object, properties){ +// let filteredProps = {}; +// let currentProperties = Object.getOwnPropertyNames(object); +// for (let i = 0; i < currentProperties.length; i++) { +// let prop = currentProperties[i]; +// if(currentProperties.indexOf(prop) < 0){ +// filteredProps[prop] = properties[prop]; +// } +// } +// oldDefine(object, filteredProps); +// }; import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; import {Input, provide, Component} from 'ng-forward'; diff --git a/webpack.config.js b/webpack.config.js index 03a47eb..e1e2098 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,7 +3,7 @@ var argv = require("yargs").argv; var path = require("path"); var glob = require("glob"); - +var webpack = require("webpack"); var extension = ".js"; if (argv.production) { @@ -22,7 +22,7 @@ var testingFiles = glob.sync("./src/app/**/*.[sS]pec.ts"); var webpackConfig = { entry: { noosfero: './src/app/index.ts', - 'noosfero-testing': testingFiles + 'test': './src/test.ts' }, @@ -30,6 +30,9 @@ var webpackConfig = { path: path.join(__dirname, "src"), filename: "[name]" + extension, }, + + /*plugins: [ new webpack.optimize.CommonsChunkPlugin("common.js") ],*/ + resolve: { // Add `.ts` and `.tsx` as a resolvable extension. extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js'] -- libgit2 0.21.2