Karma-Coverage always outputs 100% - karma-jasmine

I'm having really hard time starting to write unit tests for my app.
My coverage always reports 100%. I did simple test adn the result should be 50% but karma-coverage doesn't think so. How ever karma progress reports right results but i need to make coverage work.
This is my karma.conf.coffee:
module.exports = (config) ->
config.set
basePath: ""
frameworks: ["jasmine"]
files: [
#"server/*_spec.js",
#"server/*.js",
#"client/app/final/.js"
#"client/*_spec.js"
"test.js"
"test_spec.js"
]
exclude: []
preprocessors: {}
reporters: ["progress", "coverage"]
preprocessors:
"test.js": ["coverage"]
coverageReporter:
type : "html",
dir : "coverage/"
port: 9876
colors: true
logLevel: config.LOG_INFO
autoWatch: false
browsers: [
"Chrome"
#"Firefox" add to package.json::devDependencies:["karma-firefox-launcher"]
#"PhantomJS" add to package.json::dependencies:["phantomjs"] and package.json::devDependencies["karma-phantomjs-launcher"]
]
singleRun: true
concurrency: Infinity
And this is test.js:
function test(a) {
return a
}
function ivo() {
return "ivo"
}
And finally test_spec.js
describe("test", function() {
it("it tests", function() {
expect(test(3)).toEqual(3);
});
});
describe("ivo", function() {
it("it ivos", function() {
expect(ivo()).toEqual("ovi");
});
});
Karma progress result:
karma start
31 12 2015 17:12:48.598:INFO [karma]: Karma v0.13.16 server started at http://localhost:9876/
31 12 2015 17:12:48.610:INFO [launcher]: Starting browser Chrome
31 12 2015 17:12:50.007:INFO [Chrome 47.0.2526 (Linux 0.0.0)]: Connected on socket q97o45wS4ctU_z4DAAAA with id 35753464
Chrome 47.0.2526 (Linux 0.0.0) ivo it ivos FAILED
Expected 'ivo' to equal 'ivo1'.
at Object.<anonymous> (/home/ivo/ivo/diplomna3/test_spec.js:9:19)
Chrome 47.0.2526 (Linux 0.0.0): Executed 2 of 2 (1 FAILED) (0.004 secs / 0.01 secs)

Test coverage indicates the percentage of the source that is tested, not the percentage of tests that pass.
Because you have two functions in test.js and there is a test for each function, the coverage is 100%.
However, only one test actually passes. So your success rate is 50%.

This are the errors
karma start --log-level=DEBUG
31 12 2015 18:24:29.017:DEBUG [plugin]: Loading plugin karma-spec-reporter.
31 12 2015 18:24:29.024:DEBUG [plugin]: Loading plugin karma-coverage.
/home/ivo/ivo/diplomna3/node_modules/di/lib/injector.js:9
throw error('No provider for "' + name + '"!');
^
Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine)
at error (/home/ivo/ivo/diplomna3/node_modules/di/lib/injector.js:22:12)
at Object.parent.get (/home/ivo/ivo/diplomna3/node_modules/di/lib/injector.js:9:13)
at [object Object].get (/home/ivo/ivo/diplomna3/node_modules/di/lib/injector.js:54:19)
at /home/ivo/ivo/diplomna3/node_modules/karma/lib/server.js:137:20
at Array.forEach (native)
at [object Object].Server._start (/home/ivo/ivo/diplomna3/node_modules/karma/lib/server.js:136:21)
at [object Object].invoke (/home/ivo/ivo/diplomna3/node_modules/di/lib/injector.js:75:15)
at [object Object].Server.start (/home/ivo/ivo/diplomna3/node_modules/karma/lib/server.js:101:18)
at Object.exports.run (/home/ivo/ivo/diplomna3/node_modules/karma/lib/cli.js:231:26)
at requireCliAndRun (/usr/local/lib/node_modules/karma-cli/bin/karma:44:16)
at /usr/local/lib/node_modules/karma-cli/bin/karma:54:12
at /usr/local/lib/node_modules/karma-cli/node_modules/resolve/lib/async.js:44:21
at ondir (/usr/local/lib/node_modules/karma-cli/node_modules/resolve/lib/async.js:187:31)
at /usr/local/lib/node_modules/karma-cli/node_modules/resolve/lib/async.js:153:39
at onex (/usr/local/lib/node_modules/karma-cli/node_modules/resolve/lib/async.js:93:22)
at /usr/local/lib/node_modules/karma-cli/node_modules/resolve/lib/async.js:24:18
at FSReqWrap.oncomplete (fs.js:83:15)
This is what i changed in the config:
reporters: ["spec", "coverage"]
plugins: ["karma-spec-reporter", "karma-coverage"]
preprocessors:
"test.js": ["coverage"]
specReporter: {}

Related

CoreUi - why nightwatch cannot run e2e tests?

I want to start working with CoreUi Admin template and create project containing unit and e2e testing.
In the begining, I install CoreUi like shown in documentation:
git clone https://github.com/coreui/coreui-free-vue-admin-template.git CoreUI-Vue
cd CoreUI-Vue
npm install
Everything is ok. Now I want to run whole unit and e2e tests:
npm run test:unit
npm run test:e2e
All unit tests run properly. But when I run e2e test I got the following errors:
> #coreui/coreui-free-vue-admin-template#3.1.4 test:e2e
> vue-cli-service test:e2e
INFO Starting development server...
[BABEL] Note: The code generator has deoptimised the styling of /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#coreui/vue/dist/coreui-vue.common.js as it exceeds the max of 500KB.
WARNING Compiled with 2 warnings 2:47:38 PM
warning
asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
css/app.10fee0d6.css (383 KiB) js/chunk-28d6db65.e7636129.js (488 KiB)
js/chunk-2d0a400c.650c6f3a.js (3.37 MiB) js/chunk-2d0ae5e6.22010046.js (390 KiB)
js/chunk-2d237b34.468fc7b7.js (1.36 MiB)
js/chunk-vendors.03b8fe62.js (687 KiB)
warning
entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
app (1.07 MiB)
js/chunk-vendors.03b8fe62.js
css/app.10fee0d6.css
js/app.94002fbe.js
App running at:
- Local: http://localhost:8080/
- Network: http://172.31.33.121:8080/
App is served in production mode.
Note this is for preview or E2E testing only.
INFO Running end-to-end tests ...
[Test] Test Suite
=================
⚠ Error connecting to localhost on port 9515.
_________________________________________________
TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (348ms)
✖ test
An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally." at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
SKIPPED:
- CoreUI Vue e2e tests
ERROR Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
at makeError (/home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:174:9)
at /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:278:16
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
bagsiur#DESKTOP-718MBR1:~/Projects/B2B/test-coreui/CoreUI-Vue$
bagsiur#DESKTOP-718MBR1:~/Projects/B2B/test-coreui/CoreUI-Vue$ npm run test:e2e
> #coreui/coreui-free-vue-admin-template#3.1.4 test:e2e
> vue-cli-service test:e2e
INFO Starting development server...
WARNING Compiled with 2 warnings 3:06:39 PM
warning
asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
css/app.10fee0d6.css (383 KiB)
js/chunk-28d6db65.e7636129.js (488 KiB)
js/chunk-2d0a400c.650c6f3a.js (3.37 MiB)
js/chunk-2d0ae5e6.22010046.js (390 KiB)
js/chunk-2d237b34.468fc7b7.js (1.36 MiB)
js/chunk-vendors.03b8fe62.js (687 KiB)
warning
entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
app (1.07 MiB)
js/chunk-vendors.03b8fe62.js
css/app.10fee0d6.css
js/app.94002fbe.js
App running at:
- Local: http://localhost:8080/
- Network: http://172.31.33.121:8080/
App is served in production mode.
Note this is for preview or E2E testing only.
INFO Running end-to-end tests ...
[Test] Test Suite
=================
⚠ Error connecting to localhost on port 9515.
_________________________________________________
TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (348ms)
✖ test
An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally." at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
SKIPPED:
- CoreUI Vue e2e tests
ERROR Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
at makeError (/home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:174:9)
at /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
I work on wsl2 and Debian. My node.js version is v13.14.0 and npm is 7.12.1. I installed chromedriver in version: ChromeDriver 2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706) and last stable google chrome: google-chrome-stable 90.0.4430.212-1
What do I miss? Where could be the cause of the error in running e2e tests?
#UPDATE: I put the configuration of Nightwatch.conf.json:
// http://nightwatchjs.org/gettingstarted#settings-file
const path = require('path')
const deepmerge = require('deepmerge')
const chromedriver = require('chromedriver')
// user may have not installed geckodriver
let geckodriver = {}
try {
geckodriver = require('geckodriver')
} catch (e) {}
const userOptions = JSON.parse(process.env.VUE_NIGHTWATCH_USER_OPTIONS || '{}')
const useSelenium = process.env.VUE_NIGHTWATCH_USE_SELENIUM === '1'
const startHeadless = process.env.VUE_NIGHTWATCH_HEADLESS === '1'
const concurrentMode = process.env.VUE_NIGHTWATCH_CONCURRENT === '1'
const chromeArgs = []
const geckoArgs = []
if (startHeadless) {
chromeArgs.push('headless')
geckoArgs.push('--headless')
}
const defaultSettings = {
src_folders: ['tests/e2e/specs'],
output_folder: 'tests/e2e/reports',
page_objects_path: 'tests/e2e/page-objects',
custom_assertions_path: 'tests/e2e/custom-assertions',
custom_commands_path: 'tests/e2e/custom-commands',
globals_path: path.resolve('tests/e2e/globals.js'),
test_workers: concurrentMode,
test_settings: {
default: {
detailed_output: !concurrentMode,
launch_url: '${VUE_DEV_SERVER_URL}'
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
chromeOptions: {
w3c: false,
args: chromeArgs
}
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
alwaysMatch: {
acceptInsecureCerts: true,
'moz:firefoxOptions': {
args: geckoArgs
}
}
},
webdriver: useSelenium ? {} : {
server_path: geckodriver.path,
port: 4444
}
}
}
}
const baseSettings = deepmerge(defaultSettings, webdriverServerSettings())
module.exports = deepmerge(baseSettings, adaptUserSettings(userOptions))
function adaptUserSettings (settings) {
// The path to nightwatch external globals file needs to be made absolute
// if it is supplied in an additional config file, due to merging of config files
if (settings.globals_path) {
settings.globals_path = path.resolve(settings.globals_path)
}
return settings
}
function webdriverServerSettings () {
if (useSelenium) {
return {
selenium: {
start_process: true,
host: '127.0.0.1',
port: 4444,
server_path: require('selenium-server').path,
cli_args: {
'webdriver.chrome.driver': chromedriver.path,
'webdriver.gecko.driver': geckodriver.path
}
}
}
}
return {
webdriver: {
start_process: true,
port: 9515,
server_path: chromedriver.path
}
}
}
Version mismatch of chromedriver and chrome is the most common reason of e2e failing like this.
ChromeDriver 2.41 supports Chrome v67-69
your google-chrome-stable 90.0.4430 needs ChromeDriver 90.0.4430

"ChromeHeadless have not captured in 60000 ms, killing." occuring only in Gitlab hosted CI/CD pipeline

When running a CI/CD pipeline on Gitlab, my Karma tests are timing out with the error:
ℹ 「wdm」: Compiled successfully.
05 08 2019 22:25:31.483:INFO [karma-server]: Karma v4.2.0 server started at http://0.0.0.0:9222/
05 08 2019 22:25:31.485:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox with concurrency 1
05 08 2019 22:25:31.488:INFO [launcher]: Starting browser ChromeHeadless
05 08 2019 22:26:31.506:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
05 08 2019 22:26:31.529:INFO [launcher]: Trying to start ChromeHeadless again (1/2).
05 08 2019 22:27:31.580:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
05 08 2019 22:27:31.600:INFO [launcher]: Trying to start ChromeHeadless again (2/2).
05 08 2019 22:28:31.659:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
05 08 2019 22:28:31.689:ERROR [launcher]: ChromeHeadless failed 2 times (timeout). Giving up.
npm ERR! Test failed. See above for more details.
This problem does not occur when running tests locally, and it does not occur when running the tests using the same Docker image with Gitlab Runner locally.
I feel like I have tried every possible configuration with karma.conf.js. I have Googled this issue relentlessly and have tried every suggestion from proxy servers, to environment variables, to flags... but alas, no luck. I have tried multiple Docker images as this was initially failing on local Gitlab Runner but I have found that the Docker image selenium/standalone-chrome:latest works fine in local Gitlab Runner.
Here is my karma.conf.js file:
const process = require('process');
process.env.CHROME_BIN = require('puppeteer').executablePath();
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
frameworks: [ 'jasmine' ],
// list of files / patterns to load in the browser
files: [
'src/**/*.spec.js'
],
// list of files / patterns to exclude
exclude: [],
// preprocess matching files before serving them to the browser
preprocessors: {
'src/**/*.spec.js': [ 'webpack' ]
},
webpack: {
// webpack configuration
mode: 'development',
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['env']
}
}
]
},
stats: {
colors: true
}
},
// test results reporter to use
reporters: [ 'spec' ],
// web server port
port: 9222,
// 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,
// plugins for karma
plugins: [
'karma-chrome-launcher',
'karma-webpack',
'karma-jasmine',
'karma-spec-reporter'
],
// start these browsers
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: [
'--headless',
'--no-sandbox',
'--disable-gpu'
]
}
},
captureTimeout: 60000,
browserDisconnectTolerance: 5,
browserDisconnectTimeout : 30000,
browserNoActivityTimeout : 30000,
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// Concurrency level
// how many browser should be started simultaneous
concurrency: 1
})
}
And here is my .gitlab-ci.yml file:
.prereq_scripts: &prereq_scripts |
sudo apt -y update && sudo curl -sL https://deb.nodesource.com/setup_10.x | sudo bash && sudo apt -y install nodejs
image: 'selenium/standalone-chrome:latest'
stages:
- test
test:
stage: test
script:
- *prereq_scripts
- npm install
- npm test
I am expecting the tests to run successfully in all three instances (local npm, local Gitlab Runner and remote Gitlab CI/CD pipeline). Currently it only runs in successfully in the first two.
In your karma.conf.js file you need to declare the CHROME_BIN variable inside the module.exports function:
module.exports = function(config) {
const process = require('process');
process.env.CHROME_BIN = require('puppeteer').executablePath();
config.set({
...
Currently, Puppeteer has an issue with Karma on Linux machines, see GitHub issue
There are plenty of solutions on how to make it works without Puppeteer if you use it just to install Headless Chromium.
I have installed it on my Jenkins Alpine machine using only two bash lines:
apk add chromium
export CHROME_BIN=/usr/bin/chromium-browser
Alternatively, you can use Docker with the same setup. One of the examples is here
Docker image with chromeheadless
for example, use a docker image of angular/ngcontainer with chrome headless for testing UI apps.
image: 'angular/ngcontainer:latest'
Also, I created one docker image with the latest chrome
image: 'anulals/angular'
https://hub.docker.com/r/angular/ngcontainer
https://hub.docker.com/r/anulals/angular

Karma not running tests. Executed 0 of 0 ERROR

I am trying to test in karma, yet every time I run Karma I get the same error:
$ karma start karma.conf.js --single-run
31 07 2018 12:56:48.134:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
31 07 2018 12:56:48.138:INFO [launcher]: Launching browser Chrome with unlimited concurrency
31 07 2018 12:56:48.144:INFO [launcher]: Starting browser Chrome
31 07 2018 12:56:49.890:INFO [Chrome 67.0.3396 (Windows 10.0.0)]: Connected on socket 2we1ypnXUlTXv5IRAAAA with id 14298953
Chrome 67.0.3396 (Windows 10.0.0): Executed 0 of 0 ERROR (0.006 secs / 0 secs)
my (mostly) auto-generated karma.conf.js
located one level above the tests at: C:\Users\king\Desktop\_REPOS\inventivangular\src
// Karma configuration
// Generated on Tue Jul 31 2018 12:30:22 GMT-0400 (Eastern Daylight Time)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: 'C:/Users/king/Desktop/_REPOS/inventivangular/src/',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'./app/*.component.ts',
'./app/*spec.ts'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// 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,
// 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,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
File path of files to test: C:\Users\king\Desktop\_REPOS\inventivangular\src\app
Wound up just running ng test from C:\Users\king\Desktop\_REPOS\inventivangular which generated its own karma.conf.js and everything worked.
If you are using auto-generated tests you may need to:
import { HttpClientTestingModule } from '#angular/common/http/testing'
and
imports: [HttpClientTestingModule]

How do I use PhantomJS with Aurelia?

When I switch from Chrome to PhantomJS I get the following errorh
Starting 'unit'...
03 08 2016 21:39:43.629:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
03 08 2016 21:39:43.643:INFO [launcher]: Starting browser PhantomJS
03 08 2016 21:39:44.355:INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: Connected on socket /#ns0iei_Fprf487aCAAAA with id 15517298
PhantomJS 2.1.1 (Linux 0.0.0) ERROR
SyntaxError: Expected an identifier but found 'originalDefine' instead
at /home/xenoterracide/IdeaProjects/rpf-ui/test/aurelia-karma.js:49
{ uid: 0,
name: 'unit',
branch: false,
error: 1,
duration: [ 1, 91922852 ],
time: 1470278384500 }
1
Here is the karma.conf.js generated by Aurelia.
"use strict";
const path = require('path');
const project = require('./aurelia_project/aurelia.json');
const tsconfig = require('./tsconfig.json');
let testSrc = [
{ pattern: project.unitTestRunner.source, included: false },
'test/aurelia-karma.js'
];
let output = project.platform.output;
let appSrc = project.build.bundles.map(x => path.join(output, x.name));
let entryIndex = appSrc.indexOf(path.join(output, project.build.loader.configTarget));
let entryBundle = appSrc.splice(entryIndex, 1)[0];
let files = [entryBundle].concat(testSrc).concat(appSrc);
module.exports = function(config) {
config.set({
basePath: '',
frameworks: [project.testFramework.id],
files: files,
exclude: [],
preprocessors: {
[project.unitTestRunner.source]: [project.transpiler.id]
},
typescriptPreprocessor: {
typescript: require('typescript'),
options: tsconfig.compilerOptions
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: false
});
};
I ran into this issue just now. I 'solved' it by modifying aurelia-karma.js at line 49 from:
let originalDefine = global.define;
to:
var originalDefine = global.define;
Currently don't have time to find a root cause for this, may come back and edit later. Suspect this might be a typescript/transpiling issue with let compatibility.
(Node v4.4.7, Karma 0.13.22, jasmine v2.4.1, Aurelia-cli v0.17.0)

Protractor : ERROR - Unable to start a WebDriver session

I wrote test cases three months back at that time they worked fine now i want to run those test cases in another system so i did basic setup. When i try to run protractor test case now they are failing with 'Unable to start a WebDriver session'. I have tried so many solutions but they didn't work for me.
Here i am attaching my protractor.conf.js file and error details.
protractor.conf.js
'use strict';
exports.config = {
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
baseUrl: 'http://localhost:' + (process.env.PORT || '3036'),
chromeOnly: true,
// To get the maximimum test screen size
onPrepare: function() {
browser.driver.manage().window().maximize();
},
// list of files / patterns to load in the browser
specs: [
'e2e/attributeSection/search_spec.js', 'e2e/attributeSection/create_spec.js',
'e2e/attributeSection/edit_spec.js', 'e2e/attribute/search_spec.js',
'e2e/attribute/create_spec.js', 'e2e/attribute/edit_spec.js',
'e2e/classification/search_spec.js', 'e2e/classification/create_spec.js',
'e2e/classification/edit_spec.js', 'e2e/classificationGroup/create_spec.js',
'e2e/classificationGroup/edit_spec.js'
],
exclude: [],
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
binary: 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe',
args: [],
extensions: [],
}
},
framework: 'jasmine',
jasmineNodeOpts: {
defaultTimeoutInterval: 60000
}
};
Error in console
Using the selenium server at http://127.0.0.1:4444/wd/hub
[launcher] Running 1 instances of WebDriver
ERROR - Unable to start a WebDriver session.
C:\Users\Cronj- 4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:145
callback(new Error(message));
^
Error: ECONNREFUSED connect ECONNREFUSED
at ClientRequest.<anonymous> (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:145:16)
at ClientRequest.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1552:9)
at Socket.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:442:13)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:155:22)
at Function.webdriver.WebDriver.createSession (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:129:30)
at [object Object].Builder.build (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\builder.js:416:22)
at [object Object].DriverProvider.getNewDriver (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\lib\driverProviders\driverProvider.js:38:7)
at [object Object].Runner.createBrowser (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\lib\runner.js:180:37)
at C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\lib\runner.js:257:21
at _fulfilled (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:797:54)
at self.promiseDispatch.done (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:826:30)
at Promise.promise.promiseDispatch (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:759:13)
Could anyone help me out? Thanks in advance
I believe the "chromeOnly" option got deprecated in v2.0.0.
chromeOnly: true,
This used to mean use "direct" mode without a selenium server. But since both firefox and chrome support direct mode, the property was renamed to "directConnect". So change that line to:
directConnect: true,
In this mode you don't need a selenium server, so you can drop the seleniumAddress property which is just confusing folks.
See https://github.com/angular/protractor/pull/1933/files
I ran webdriver-manager start in one command prompt and protractor in another command prompt then only test cases started running