From 2168a9e67b3068f848046d37102e6dba01451921 Mon Sep 17 00:00:00 2001 From: Tobias Schwarz Date: Mon, 13 Mar 2017 15:06:23 +0100 Subject: [PATCH 01/15] webpack angular test integration --- src/karma.conf.js | 76 +++++++++++++++++++++++++++++++++++++ src/package.json | 15 +++++++- src/webpack.config.babel.js | 29 +++++++++----- 3 files changed, 109 insertions(+), 11 deletions(-) create mode 100644 src/karma.conf.js diff --git a/src/karma.conf.js b/src/karma.conf.js new file mode 100644 index 000000000..93e16d733 --- /dev/null +++ b/src/karma.conf.js @@ -0,0 +1,76 @@ +var path = require('path'); +var webpackConfig = require('./webpack.config.babel'); +var entry = path.resolve(__dirname + '/app', './app/index.js'); //accessing [0] because there are mutli entry points for webpack hot loader +var preprocessors = {}; +preprocessors[entry] = ['webpack']; +preprocessors['**/*.html'] = ['ng-html2js']; + +module.exports = function(config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['mocha', 'chai'], + + // list of files / patterns to load in the browser + files: [entry], + webpack: webpackConfig, + + // list of files to exclude + exclude: [], + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress'], + + preprocessors: preprocessors, + + babelPreprocessor: { + options: { + presets: ['es2015'] + } + }, + + // web server port + port: 9876, + + // enable / disable colors in the output (reporters and logs) + colors: true, + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + ngHtml2JsPreprocessor: { + stripPrefix: 'app/components/', + moduleName: 'my.templates' + }, + + reporters: ['mocha'], + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['Chrome'], + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, + + plugins: [ + require('karma-webpack'), + 'karma-chai', + 'karma-mocha', + 'karma-chrome-launcher', + 'karma-ng-html2js-preprocessor', + 'karma-mocha-reporter' + ] + }); +} \ No newline at end of file diff --git a/src/package.json b/src/package.json index cce9042a0..7b7ef4084 100644 --- a/src/package.json +++ b/src/package.json @@ -5,13 +5,13 @@ "scripts": { "build": "webpack --profile --progress --display-modules --display-exclude --display-chunks --display-cached --display-cached-assets", "dev": "webpack-dev-server --host 0.0.0.0 --profile --progress", - "test": "grunt test && nyc mocha" + "test": "export NODE_ENV=test && karma start" }, "dependencies": { "angular": "=1.5.8", "angular-animate": "=1.5.8", - "angular-cookies": "=1.5.8", "angular-aria": "=1.5.8", + "angular-cookies": "=1.5.8", "angular-material": "=1.1.1", "angular-material-data-table": "=0.10.9", "angular-messages": "=1.5.8", @@ -24,11 +24,13 @@ "numeral": "=1.5.3" }, "devDependencies": { + "angular-mocks": "^1.6.3", "babel-core": "=6.9.1", "babel-loader": "=6.2.4", "babel-plugin-syntax-trailing-function-commas": "=6.22.0", "babel-polyfill": "=6.9.1", "babel-preset-es2015": "=6.9.0", + "chai": "^3.5.0", "clean-webpack-plugin": "=0.1.9", "css-loader": "=0.23.1", "eslint-config-airbnb": "=14.1.0", @@ -43,6 +45,15 @@ "imports-loader": "=0.6.5", "jit-grunt": "=0.10.0", "json-loader": "=0.5.4", + "karma": "^1.5.0", + "karma-babel-preprocessor": "^6.0.1", + "karma-chai": "^0.1.0", + "karma-chrome-launcher": "^2.0.0", + "karma-mocha": "^1.3.0", + "karma-mocha-reporter": "^2.2.2", + "karma-ng-html2js-preprocessor": "^1.0.0", + "karma-verbose-reporter": "0.0.6", + "karma-webpack": "^2.0.2", "less": "=2.7.1", "less-loader": "=2.2.3", "mocha": "=3.2.0", diff --git a/src/webpack.config.babel.js b/src/webpack.config.babel.js index 6298484b8..20c8b2755 100644 --- a/src/webpack.config.babel.js +++ b/src/webpack.config.babel.js @@ -1,14 +1,24 @@ -import path from 'path' +//import path from 'path' -import webpack from 'webpack' -import merge from 'webpack-merge' -import validate from 'webpack-validator' -import HtmlWebpackPlugin from 'html-webpack-plugin' -import ngAnnotatePlugin from 'ng-annotate-webpack-plugin' -import CleanWebpackPlugin from 'clean-webpack-plugin' +var path = require('path'); -import pkg from './package' +//import webpack from 'webpack' +//import merge from 'webpack-merge' +//import validate from 'webpack-validator' +//import HtmlWebpackPlugin from 'html-webpack-plugin' +//import ngAnnotatePlugin from 'ng-annotate-webpack-plugin' +//import CleanWebpackPlugin from 'clean-webpack-plugin' + + +var webpack = require('webpack'); +var merge = require('webpack-merge'); +var validate = require('webpack-validator'); +var HtmlWebpackPlugin = require('html-webpack-plugin'); +var ngAnnotatePlugin = require('ng-annotate-webpack-plugin'); +var CleanWebpackPlugin = require('clean-webpack-plugin'); + +//import pkg from './package' const PATHS = { app: path.join(__dirname, 'app'), @@ -230,4 +240,5 @@ switch(process.env.npm_lifecycle_event) { break } -export default validate(config) +//export default validate(config) +module.exports = validate(config); \ No newline at end of file From 293aae22518b09a2c1781ca9d583bded10b837dc Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Tue, 14 Mar 2017 09:26:29 +0100 Subject: [PATCH 02/15] Switch unit test browser to PhantomJS --- src/karma.conf.js | 5 +++-- src/package.json | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/karma.conf.js b/src/karma.conf.js index 93e16d733..55b79c0a0 100644 --- a/src/karma.conf.js +++ b/src/karma.conf.js @@ -58,7 +58,7 @@ module.exports = function(config) { // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['Chrome'], + browsers: ['PhantomJS'], // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits @@ -70,7 +70,8 @@ module.exports = function(config) { 'karma-mocha', 'karma-chrome-launcher', 'karma-ng-html2js-preprocessor', - 'karma-mocha-reporter' + 'karma-mocha-reporter', + 'karma-phantomjs-launcher' ] }); } \ No newline at end of file diff --git a/src/package.json b/src/package.json index 7b7ef4084..2f27ba652 100644 --- a/src/package.json +++ b/src/package.json @@ -52,6 +52,7 @@ "karma-mocha": "^1.3.0", "karma-mocha-reporter": "^2.2.2", "karma-ng-html2js-preprocessor": "^1.0.0", + "karma-phantomjs-launcher": "=1.0.4", "karma-verbose-reporter": "0.0.6", "karma-webpack": "^2.0.2", "less": "=2.7.1", @@ -59,6 +60,8 @@ "mocha": "=3.2.0", "ng-annotate-webpack-plugin": "=0.1.2", "nyc": "=10.1.2", + "phantomjs": "=2.1.7", + "phantomjs-prebuilt": "=2.1.14", "pug": "=2.0.0-beta11", "pug-cli": "=1.0.0-alpha6", "pug-loader": "=2.3.0", From df664f2b6a7e20e8f46924068cf5e95c419a2215 Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Tue, 14 Mar 2017 11:43:58 +0100 Subject: [PATCH 03/15] Set up karma to run the first angular unit test --- src/karma.conf.js | 30 ++++++++++++++++++++++------- src/package.json | 21 ++++++++++---------- src/test/components/top/top.spec.js | 26 +++++++++++++++++++++++++ src/test/test.js | 11 ++++------- src/webpack.config.babel.js | 18 ++++------------- 5 files changed, 68 insertions(+), 38 deletions(-) create mode 100644 src/test/components/top/top.spec.js diff --git a/src/karma.conf.js b/src/karma.conf.js index 55b79c0a0..b1f0d90af 100644 --- a/src/karma.conf.js +++ b/src/karma.conf.js @@ -1,9 +1,12 @@ var path = require('path'); var webpackConfig = require('./webpack.config.babel'); -var entry = path.resolve(__dirname + '/app', './app/index.js'); //accessing [0] because there are mutli entry points for webpack hot loader +// var entry = path.resolve(webpackConfig.entry.app, '..', '..', 'app', 'app.js'); //accessing [0] because there are mutli entry points for webpack hot loader var preprocessors = {}; -preprocessors[entry] = ['webpack']; +//preprocessors[entry] = ['webpack']; preprocessors['**/*.html'] = ['ng-html2js']; +var test = path.join(__dirname, 'test', 'test.js'); +preprocessors[test] = ['webpack']; +preprocessors['app/**/*.js'] = ['coverage']; module.exports = function(config) { config.set({ @@ -16,7 +19,7 @@ module.exports = function(config) { frameworks: ['mocha', 'chai'], // list of files / patterns to load in the browser - files: [entry], + files: [test], webpack: webpackConfig, // list of files to exclude @@ -25,7 +28,7 @@ module.exports = function(config) { // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress'], + reporters: ['progress', 'coverage'], preprocessors: preprocessors, @@ -47,7 +50,7 @@ module.exports = function(config) { // enable / disable watching file and executing tests whenever any file changes - autoWatch: true, + autoWatch: false, ngHtml2JsPreprocessor: { stripPrefix: 'app/components/', @@ -56,13 +59,25 @@ module.exports = function(config) { reporters: ['mocha'], + coverageReporter: { + type : 'html', + dir : 'coverage/' + }, + + // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher browsers: ['PhantomJS'], // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits - singleRun: false, + singleRun: true, + client: { + mocha: { + opts: 'test/mocha.opts' // You can set opts to equal true then plugin will load opts from default location 'test/mocha.opts' + }, + }, + plugins: [ require('karma-webpack'), @@ -71,7 +86,8 @@ module.exports = function(config) { 'karma-chrome-launcher', 'karma-ng-html2js-preprocessor', 'karma-mocha-reporter', + 'karma-coverage', 'karma-phantomjs-launcher' ] }); -} \ No newline at end of file +} diff --git a/src/package.json b/src/package.json index 2f27ba652..b1b4b6707 100644 --- a/src/package.json +++ b/src/package.json @@ -24,13 +24,13 @@ "numeral": "=1.5.3" }, "devDependencies": { - "angular-mocks": "^1.6.3", + "angular-mocks": "=1.5.8", "babel-core": "=6.9.1", "babel-loader": "=6.2.4", "babel-plugin-syntax-trailing-function-commas": "=6.22.0", "babel-polyfill": "=6.9.1", "babel-preset-es2015": "=6.9.0", - "chai": "^3.5.0", + "chai": "=3.5.0", "clean-webpack-plugin": "=0.1.9", "css-loader": "=0.23.1", "eslint-config-airbnb": "=14.1.0", @@ -38,7 +38,7 @@ "exports-loader": "=0.6.3", "extract-text-webpack-plugin": "=1.0.1", "file-loader": "=0.9.0", - "git-hooks": "^1.1.8", + "git-hooks": "=1.1.8", "grunt": "=1.0.1", "grunt-eslint": "=19.0.0", "html-webpack-plugin": "=2.19.0", @@ -46,15 +46,16 @@ "jit-grunt": "=0.10.0", "json-loader": "=0.5.4", "karma": "^1.5.0", - "karma-babel-preprocessor": "^6.0.1", - "karma-chai": "^0.1.0", - "karma-chrome-launcher": "^2.0.0", - "karma-mocha": "^1.3.0", - "karma-mocha-reporter": "^2.2.2", - "karma-ng-html2js-preprocessor": "^1.0.0", + "karma-babel-preprocessor": "=6.0.1", + "karma-chai": "=0.1.0", + "karma-chrome-launcher": "=2.0.0", + "karma-coverage": "^1.1.1", + "karma-mocha": "=1.3.0", + "karma-mocha-reporter": "=2.2.2", + "karma-ng-html2js-preprocessor": "=1.0.0", "karma-phantomjs-launcher": "=1.0.4", "karma-verbose-reporter": "0.0.6", - "karma-webpack": "^2.0.2", + "karma-webpack": "=2.0.2", "less": "=2.7.1", "less-loader": "=2.2.3", "mocha": "=3.2.0", diff --git a/src/test/components/top/top.spec.js b/src/test/components/top/top.spec.js new file mode 100644 index 000000000..8d96e5adc --- /dev/null +++ b/src/test/components/top/top.spec.js @@ -0,0 +1,26 @@ +var expect = require('chai').expect; + +describe('Top component', function() { + var $compile, + $rootScope; + + // Load the myApp module, which contains the directive + beforeEach(angular.mock.module("app")); + + // Store references to $rootScope and $compile + // so they are available to all tests in this describe block + beforeEach(inject(function(_$compile_, _$rootScope_){ + // The injector unwraps the underscores (_) from around the parameter names when matching + $compile = _$compile_; + $rootScope = _$rootScope_; + })); + + it('should contain address', function() { + // Compile a piece of HTML containing the directive + var element = $compile("")($rootScope); + // fire all the watches, so the scope expression {{1 + 1}} will be evaluated + $rootScope.$digest(); + // Check that the compiled element contains the templated content + expect(element.html()).to.contain("address"); + }); +}); diff --git a/src/test/test.js b/src/test/test.js index 07fc6b9be..2832d6709 100644 --- a/src/test/test.js +++ b/src/test/test.js @@ -1,9 +1,6 @@ -var should = require('should'); +require('../app'); -describe('Example Test', function () { +require('angular-mocks/angular-mocks'); + +require('./components/top/top.spec'); - it('should show an example', function () { - var x = 5; - (x).should.be.equal(5); - }); -}); diff --git a/src/webpack.config.babel.js b/src/webpack.config.babel.js index 20c8b2755..915d48b40 100644 --- a/src/webpack.config.babel.js +++ b/src/webpack.config.babel.js @@ -1,16 +1,6 @@ -//import path from 'path' - var path = require('path'); -//import webpack from 'webpack' -//import merge from 'webpack-merge' -//import validate from 'webpack-validator' -//import HtmlWebpackPlugin from 'html-webpack-plugin' -//import ngAnnotatePlugin from 'ng-annotate-webpack-plugin' -//import CleanWebpackPlugin from 'clean-webpack-plugin' - - var webpack = require('webpack'); var merge = require('webpack-merge'); var validate = require('webpack-validator'); @@ -18,7 +8,7 @@ var HtmlWebpackPlugin = require('html-webpack-plugin'); var ngAnnotatePlugin = require('ng-annotate-webpack-plugin'); var CleanWebpackPlugin = require('clean-webpack-plugin'); -//import pkg from './package' +var nodeEnvironment = process.env.NODE_ENV; const PATHS = { app: path.join(__dirname, 'app'), @@ -26,12 +16,12 @@ const PATHS = { } const common = { - entry: { + entry: nodeEnvironment == 'test' ? { } : { app: PATHS.app, }, output: { path: PATHS.build, - filename: `app.js`, + filename: 'app.js', }, node: { fs: 'empty' @@ -241,4 +231,4 @@ switch(process.env.npm_lifecycle_event) { } //export default validate(config) -module.exports = validate(config); \ No newline at end of file +module.exports = validate(config); From 6a81a0777fa5c3be708e3efee5b36c88f127c052 Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Wed, 15 Mar 2017 10:00:53 +0100 Subject: [PATCH 04/15] Setup test coverage that works with angular --- src/app/index.js | 32 ++------------------------------ src/app/libs.js | 13 +++++++++++++ src/app/lisk-nano.js | 18 ++++++++++++++++++ src/karma.conf.js | 15 ++++++++------- src/test/test.js | 2 -- 5 files changed, 41 insertions(+), 39 deletions(-) create mode 100644 src/app/libs.js create mode 100644 src/app/lisk-nano.js diff --git a/src/app/index.js b/src/app/index.js index 57ca76e60..d9889c85c 100644 --- a/src/app/index.js +++ b/src/app/index.js @@ -1,34 +1,6 @@ -import 'jquery'; - -import 'angular'; -import 'angular-animate'; -import 'angular-cookies'; -import 'angular-aria'; -import 'angular-messages'; -import 'angular-material'; -import 'angular-material/angular-material.css'; -import 'angular-material-data-table/dist/md-data-table'; -import 'angular-material-data-table/dist/md-data-table.css'; - -import './index.less'; - -import './theme/theme'; -import './util/animateOnChange/animateOnChange'; -import './components/main/main'; -import './components/login/login'; -import './components/top/top'; -import './components/send/send'; -import './components/transactions/transactions'; -import './components/timestamp/timestamp'; -import './components/lsk/lsk'; - -import './services/peers/peers'; -import './services/lsk'; -import './services/success'; -import './services/error'; - -import './filters/lsk'; +import './libs'; +import './app'; angular.element(document).ready(() => { angular.bootstrap(document, ['app']); diff --git a/src/app/libs.js b/src/app/libs.js new file mode 100644 index 000000000..cdcd5949a --- /dev/null +++ b/src/app/libs.js @@ -0,0 +1,13 @@ + +import 'jquery'; + +import 'angular'; +import 'angular-animate'; +import 'angular-cookies'; +import 'angular-aria'; +import 'angular-messages'; +import 'angular-material'; +import 'angular-material/angular-material.css'; +import 'angular-material-data-table/dist/md-data-table'; +import 'angular-material-data-table/dist/md-data-table.css'; + diff --git a/src/app/lisk-nano.js b/src/app/lisk-nano.js new file mode 100644 index 000000000..76203ee5c --- /dev/null +++ b/src/app/lisk-nano.js @@ -0,0 +1,18 @@ +import './index.less'; + +import './theme/theme'; +import './util/animateOnChange/animateOnChange'; +import './components/main/main'; +import './components/login/login'; +import './components/top/top'; +import './components/send/send'; +import './components/transactions/transactions'; +import './components/timestamp/timestamp'; +import './components/lsk/lsk'; + +import './services/peers/peers'; +import './services/lsk'; +import './services/success'; +import './services/error'; + +import './filters/lsk'; diff --git a/src/karma.conf.js b/src/karma.conf.js index b1f0d90af..e3fa22b5c 100644 --- a/src/karma.conf.js +++ b/src/karma.conf.js @@ -4,9 +4,12 @@ var webpackConfig = require('./webpack.config.babel'); var preprocessors = {}; //preprocessors[entry] = ['webpack']; preprocessors['**/*.html'] = ['ng-html2js']; +var libs = path.join(__dirname, 'app', 'libs.js'); +var app = path.join(__dirname, 'app', 'lisk-nano.js'); var test = path.join(__dirname, 'test', 'test.js'); +preprocessors[libs] = ['webpack']; +preprocessors[app] = ['webpack', 'coverage']; preprocessors[test] = ['webpack']; -preprocessors['app/**/*.js'] = ['coverage']; module.exports = function(config) { config.set({ @@ -19,7 +22,7 @@ module.exports = function(config) { frameworks: ['mocha', 'chai'], // list of files / patterns to load in the browser - files: [test], + files: [libs, app, test], webpack: webpackConfig, // list of files to exclude @@ -28,7 +31,7 @@ module.exports = function(config) { // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress', 'coverage'], + reporters: ['progress', 'mocha', 'coverage'], preprocessors: preprocessors, @@ -57,11 +60,9 @@ module.exports = function(config) { moduleName: 'my.templates' }, - reporters: ['mocha'], - coverageReporter: { - type : 'html', - dir : 'coverage/' + type : 'text', + dir : 'coverage/', }, diff --git a/src/test/test.js b/src/test/test.js index 2832d6709..bd83a31e6 100644 --- a/src/test/test.js +++ b/src/test/test.js @@ -1,5 +1,3 @@ -require('../app'); - require('angular-mocks/angular-mocks'); require('./components/top/top.spec'); From 6f395d1ab43a67c475951d49325ab42daa1df56c Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Wed, 15 Mar 2017 10:29:48 +0100 Subject: [PATCH 05/15] Add coveralls badge to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4701667eb..1f9d93752 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ [![Build Status](https://travis-ci.org/LiskHQ/lisk-nano.svg?branch=development)](https://travis-ci.org/LiskHQ/lisk-nano) +[![Coverage Status](https://coveralls.io/repos/github/LiskHQ/lisk-nano/badge.svg?branch=development)](https://coveralls.io/github/LiskHQ/lisk-nano?branch=development) + ## Development ``` From 9d472fedb2a07445e1caaa4aca901a664980863d Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Wed, 15 Mar 2017 11:40:20 +0100 Subject: [PATCH 06/15] Add babel-plugin-istambul ... to make test coverage work --- src/package.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/package.json b/src/package.json index b1b4b6707..86f367146 100644 --- a/src/package.json +++ b/src/package.json @@ -28,6 +28,7 @@ "babel-core": "=6.9.1", "babel-loader": "=6.2.4", "babel-plugin-syntax-trailing-function-commas": "=6.22.0", + "babel-plugin-istanbul": "^4.0.0", "babel-polyfill": "=6.9.1", "babel-preset-es2015": "=6.9.0", "chai": "=3.5.0", @@ -80,5 +81,10 @@ "es2015" ], "plugins": ["syntax-trailing-function-commas"] + "env": { + "test": { + "plugins": [ "istanbul" ] + } + } } } From b6e98b9bb34d29d9f33dfc4f6e75721f881add0d Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Wed, 15 Mar 2017 11:53:49 +0100 Subject: [PATCH 07/15] Create a second sample test ... to see if coverage is affected --- src/test/components/login/login.spec.js | 23 +++++++++++++++++++++++ src/test/components/top/top.spec.js | 2 -- src/test/test.js | 2 ++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 src/test/components/login/login.spec.js diff --git a/src/test/components/login/login.spec.js b/src/test/components/login/login.spec.js new file mode 100644 index 000000000..ae31f9289 --- /dev/null +++ b/src/test/components/login/login.spec.js @@ -0,0 +1,23 @@ +describe('Login component', function() { + var $compile, + $rootScope; + + // Load the myApp module, which contains the directive + beforeEach(angular.mock.module("app")); + + // Store references to $rootScope and $compile + // so they are available to all tests in this describe block + beforeEach(inject(function(_$compile_, _$rootScope_){ + // The injector unwraps the underscores (_) from around the parameter names when matching + $compile = _$compile_; + $rootScope = _$rootScope_; + })); + + it('should contain header', function() { + // Compile a piece of HTML containing the directive + var element = $compile("")($rootScope); + $rootScope.$digest(); + expect(element.html()).to.contain("Sign In"); + }); +}); + diff --git a/src/test/components/top/top.spec.js b/src/test/components/top/top.spec.js index 8d96e5adc..21eb13d16 100644 --- a/src/test/components/top/top.spec.js +++ b/src/test/components/top/top.spec.js @@ -1,5 +1,3 @@ -var expect = require('chai').expect; - describe('Top component', function() { var $compile, $rootScope; diff --git a/src/test/test.js b/src/test/test.js index bd83a31e6..b94d3d352 100644 --- a/src/test/test.js +++ b/src/test/test.js @@ -1,4 +1,6 @@ require('angular-mocks/angular-mocks'); +require('chai/chai'); +require('./components/login/login.spec'); require('./components/top/top.spec'); From d92fe0b47bc4197b69ade2a25eabb2914db65948 Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Wed, 15 Mar 2017 11:54:47 +0100 Subject: [PATCH 08/15] index.js was importing wrong file --- src/app/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/index.js b/src/app/index.js index d9889c85c..42f1cce52 100644 --- a/src/app/index.js +++ b/src/app/index.js @@ -1,6 +1,6 @@ import './libs'; -import './app'; +import './lisk-nano'; angular.element(document).ready(() => { angular.bootstrap(document, ['app']); From 847af82b727999db5254cc98734f206e215a0ee3 Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Wed, 15 Mar 2017 12:06:00 +0100 Subject: [PATCH 09/15] Add coveralls to karma --- src/karma.conf.js | 3 ++- src/package.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/karma.conf.js b/src/karma.conf.js index e3fa22b5c..5b56995ce 100644 --- a/src/karma.conf.js +++ b/src/karma.conf.js @@ -31,7 +31,7 @@ module.exports = function(config) { // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress', 'mocha', 'coverage'], + reporters: ['progress', 'mocha', 'coverage', 'coveralls'], preprocessors: preprocessors, @@ -88,6 +88,7 @@ module.exports = function(config) { 'karma-ng-html2js-preprocessor', 'karma-mocha-reporter', 'karma-coverage', + 'karma-coveralls', 'karma-phantomjs-launcher' ] }); diff --git a/src/package.json b/src/package.json index 86f367146..0392aec89 100644 --- a/src/package.json +++ b/src/package.json @@ -51,6 +51,7 @@ "karma-chai": "=0.1.0", "karma-chrome-launcher": "=2.0.0", "karma-coverage": "^1.1.1", + "karma-coveralls": "^1.1.2", "karma-mocha": "=1.3.0", "karma-mocha-reporter": "=2.2.2", "karma-ng-html2js-preprocessor": "=1.0.0", From 0884792ce4a3973e6112c43d1dd56d8bc5de7741 Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Wed, 15 Mar 2017 13:50:31 +0100 Subject: [PATCH 10/15] Fix chai require statement --- src/test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/test.js b/src/test/test.js index b94d3d352..94069b6f7 100644 --- a/src/test/test.js +++ b/src/test/test.js @@ -1,5 +1,5 @@ require('angular-mocks/angular-mocks'); -require('chai/chai'); +require('chai'); require('./components/login/login.spec'); require('./components/top/top.spec'); From e0c26e5e543e4589b98c7dafe5cf0e09c4c52344 Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Wed, 15 Mar 2017 14:20:21 +0100 Subject: [PATCH 11/15] Change coverageReporter type to lcov --- src/karma.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/karma.conf.js b/src/karma.conf.js index 5b56995ce..5ff8eb842 100644 --- a/src/karma.conf.js +++ b/src/karma.conf.js @@ -61,7 +61,7 @@ module.exports = function(config) { }, coverageReporter: { - type : 'text', + type : 'lcov', dir : 'coverage/', }, From b961bf1b2616e40f9e0ada8a6ff3dc9d9d5fb584 Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Wed, 15 Mar 2017 15:43:34 +0100 Subject: [PATCH 12/15] Run coveralls only in travis --- .travis.yml | 2 ++ src/karma.conf.js | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ea6071b7b..4ddb3a185 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ language: node_js node_js: - 'node' # Latest stable Node.js release +env: + - ON_TRAVIS=true before_install: cd src before_script: - npm install -g grunt diff --git a/src/karma.conf.js b/src/karma.conf.js index 5ff8eb842..6f0b50e8f 100644 --- a/src/karma.conf.js +++ b/src/karma.conf.js @@ -11,6 +11,10 @@ preprocessors[libs] = ['webpack']; preprocessors[app] = ['webpack', 'coverage']; preprocessors[test] = ['webpack']; +var opts = { + onTravis: process.env.ON_TRAVIS, +}; + module.exports = function(config) { config.set({ @@ -31,7 +35,7 @@ module.exports = function(config) { // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress', 'mocha', 'coverage', 'coveralls'], + reporters: ['progress', 'mocha', 'coverage'].concat(opts.onTravis ? ['coveralls'] : []), preprocessors: preprocessors, @@ -61,7 +65,7 @@ module.exports = function(config) { }, coverageReporter: { - type : 'lcov', + type : opts.onTravis ? 'lcov' : 'text', dir : 'coverage/', }, From e15fffd77b6115c335d2872191b48c1867451f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Stanislav?= Date: Wed, 15 Mar 2017 15:44:24 +0100 Subject: [PATCH 13/15] Put coveralls badge on line with travis badge --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 1f9d93752..eb23a7efb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Lisk Nano [![Build Status](https://travis-ci.org/LiskHQ/lisk-nano.svg?branch=development)](https://travis-ci.org/LiskHQ/lisk-nano) - [![Coverage Status](https://coveralls.io/repos/github/LiskHQ/lisk-nano/badge.svg?branch=development)](https://coveralls.io/github/LiskHQ/lisk-nano?branch=development) ## Development From 64ab5e7782109595312fd741fece71be9670477d Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Wed, 15 Mar 2017 16:23:08 +0100 Subject: [PATCH 14/15] Package.json formated by npm --- src/package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/package.json b/src/package.json index 0392aec89..94d1917f2 100644 --- a/src/package.json +++ b/src/package.json @@ -84,7 +84,9 @@ "plugins": ["syntax-trailing-function-commas"] "env": { "test": { - "plugins": [ "istanbul" ] + "plugins": [ + "istanbul" + ] } } } From 2fba668f5ee52f6a5e9feffd4f2a47bdad0c8015 Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Wed, 15 Mar 2017 16:54:56 +0100 Subject: [PATCH 15/15] Fix package.json syntax --- src/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/package.json b/src/package.json index 94d1917f2..619804cac 100644 --- a/src/package.json +++ b/src/package.json @@ -81,7 +81,7 @@ "presets": [ "es2015" ], - "plugins": ["syntax-trailing-function-commas"] + "plugins": ["syntax-trailing-function-commas"], "env": { "test": { "plugins": [