From 1238e73bd8d1a1fb66dd0e5c3031d41a0b59de97 Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Fri, 17 Mar 2017 17:31:58 +0100 Subject: [PATCH] Create a command to run tests on file change: npm run test-live --- src/karma.conf.js | 5 +++-- src/package.json | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/karma.conf.js b/src/karma.conf.js index 66a1f776c..c5ab74762 100644 --- a/src/karma.conf.js +++ b/src/karma.conf.js @@ -13,6 +13,7 @@ preprocessors[test] = ['webpack']; var opts = { onTravis: process.env.ON_TRAVIS, + live: process.env.LIVE, }; module.exports = function(config) { @@ -57,7 +58,7 @@ module.exports = function(config) { // enable / disable watching file and executing tests whenever any file changes - autoWatch: false, + autoWatch: opts.live, ngHtml2JsPreprocessor: { stripPrefix: 'app/components/', @@ -77,7 +78,7 @@ module.exports = function(config) { // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits - singleRun: true, + singleRun: !opts.live, client: { mocha: { opts: 'test/mocha.opts' // You can set opts to equal true then plugin will load opts from default location 'test/mocha.opts' diff --git a/src/package.json b/src/package.json index 619804cac..7847c80ed 100644 --- a/src/package.json +++ b/src/package.json @@ -5,7 +5,8 @@ "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": "export NODE_ENV=test && karma start" + "test": "export NODE_ENV=test && karma start", + "test-live": "export NODE_ENV=test && export LIVE=true && karma start" }, "dependencies": { "angular": "=1.5.8",