Ismael
Ismael

Reputation: 85

Angular 6 run karma tests from IntelliJ

I just upgraded my angular application from version 5.2 to version 6. Everything is working fine but when i tried to run a test from IntelliJ it throws the following error:

Error: The '@angular-devkit/build-angular/plugins/karma' karma plugin is meant to be used from within Angular CLI and will not work correctly outside of it.

In the previous version i could run the same test from IntelliJ.

In any case i can run the tests from the command line but i would like to fix this problem.

This is my package.json:

{
  "name": "projectname",
  "version": "1.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "build-prod": "ng build --output-hashing all --extract-css true --named-chunks false --sourcemaps false --environment prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^1.0.0-beta.2",
    "@angular/animations": "6.0.0",
    "@angular/cdk": "6.0.1",
    "@angular/common": "6.0.0",
    "@angular/compiler": "6.0.0",
    "@angular/core": "6.0.0",
    "@angular/forms": "6.0.0",
    "@angular/http": "6.0.0",
    "@angular/material": "6.0.1",
    "@angular/platform-browser": "6.0.0",
    "@angular/platform-browser-dynamic": "6.0.0",
    "@angular/router": "6.0.0",
    "@types/d3": "^5.0.0",
    "angular-oauth2-oidc": "3.1.4",
    "angular2-jwt": "0.2.3",
    "bootstrap": "^4.0.0-beta.3",
    "clean-css": "^4.1.11",
    "core-js": "^2.4.1",
    "d3": "^4.13.0",
    "font-awesome": "^4.7.0",
    "hammerjs": "2.0.8",
    "jquery": "^3.3.1",
    "moment": "2.20.1",
    "ngx-bootstrap": "^2.0.2",
    "npm": "^5.7.1",
    "popper.js": "^1.12.9",
    "rxjs": "^6.1.0",
    "rxjs-compat": "^6.1.0",
    "tether": "1.4.3",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular/cli": "6.0.0",
    "@angular/compiler-cli": "6.0.0",
    "@angular/language-service": "6.0.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-reporters": "~2.3.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-junit-reporter": "^1.2.0",
    "protractor": "~5.1.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "2.7.2",
    "@angular-devkit/build-angular": "~0.6.0"
  }
}

Upvotes: 4

Views: 7930

Answers (2)

user3444999
user3444999

Reputation: 571

Although this Issue got fixed in Version 2018.3 but I had to some settings modification.

I ended up fixing this in IntelliJ's Web Storm :

Run > Edit Configurations > Run/Debug Conigurations > left panel (Seleck Karma and that specific test) > change the karma package to ~\Desktop\IronMan\Jarvis\node_modules\@angular\cli

And then run debug test for specific test. Check this -> https://github.com/angular/angular-cli/issues/12108

Upvotes: 2

lena
lena

Reputation: 93728

Known issue, caused by recent changes in Angular CLI. Here's an issue about that in the angular-cli repo: https://github.com/angular/angular-cli/issues/10703. Related JetBrains ticket: WEB-32653. Please follow it for updates

Upvotes: 6

Related Questions