Search code examples
npmkarma-runnerkarma-jasmineterminatebuild-definition

Karma tests process is not autoterminating despite of a 'single' argument


I am creating a build definition on VSTS and I need the task to end in order to start next one.

When I execute

npm run test:single

the tests execute but then the process is not killed automatically and if I press ctrl + c I get an inquiry Terminate batch job (y/n) and even if I hit y then upon next ctrl + c I see

C:\GIT\data>[0] 12 06 2017 11:17:26.232:DEBUG [launcher]: Disconnecting all browsers

In pacakges.json test single is defined as:

"test:single": "npm run tsc && concurrently \"npm run karma-jasmine:autoclose\""

The version of Karma is: "@types/jasmine": "2.5.47"

Question: How to make tests' process terminate when the karma finishes execution of my tests.

Part of package.json:

"scripts": {
    "ci": "npm run lint && npm run format && npm run test:single && npm run test-node",
    "format": "gulp format:enforce",
    "karma-jasmine": "karma start karma-build-jasmine.conf.js",
    "karma-jasmine:single": "karma start karma-build-jasmine.conf.js --single-run",
    "karma-jasmine:autoclose": "npm run karma-jasmine:single",
    "lint": "gulp lint",
    "prepublish": "tsc && gulp build",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "test": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run karma-jasmine\"",
    "test:single": "npm run tsc && concurrently  \"npm run karma-jasmine:autoclose\"",
    "test-dist": "concurrently \"npm run tsc:w\"  \"karma start karma-dist-jasmine.conf.js\"",
    "test-node": "gulp test/node"
  },
  "repository": {
    "type": "git",
    "url": "git://github.com/xxx"
  },
  "bugs": {
    "url": "https://github.com/xxx"
  },
  "dependencies": {},
  "devDependencies": {
    "@types/jasmine": "2.5.47",
    "@types/node": "^7.0.18",
    "@types/systemjs": "^0.20.2",
    "clang-format": "1.0.51",
    "concurrently": "^3.4.0",
    "es6-promise": "^4.1.0",
    "gulp": "^3.8.11",
    "gulp-clang-format": "^1.0.23",
    "gulp-rename": "^1.2.2",
    "gulp-rollup": "^2.3.0",
    "gulp-tsc": "^1.1.4",
    "gulp-tslint": "^8.0.0",
    "gulp-uglify": "^2.1.2",
    "gulp-util": "^3.0.7",
    "jasmine": "^2.4.1",
    "jasmine-core": "^2.2.0",
    "karma": "^1.7.0",
    "karma-chrome-launcher": "^2.1.1",
    "karma-firefox-launcher": "^1.0.1",
    "karma-jasmine": "^1.1.0",
    "karma-mocha": "^1.2.0",
    "karma-safari-launcher": "^1.0.0",
    "karma-sourcemap-loader": "^0.3.6",
    "karma-spec-reporter-2": "^0.2.0",
    "mocha": "^3.1.2",
    "pump": "^1.0.1",
    "rewire": "^2.5.2",
    "systemjs": "^0.20.12",
    "ts-loader": "^2.0.3",
    "tslint": "^5.2.0",
    "tslint-eslint-rules": "^4.0.0",
    "typescript": "2.3.2",
    "vrsource-tslint-rules": "^5.1.0",
    "whatwg-fetch": "^2.0.1"
  }
}

Solution

  • I needed to remove spec reporter as it didn't terminate itself after printing the output.