简体   繁体   English

来自IntelliJ的Angular 6运行业力测试

[英]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: 我刚刚将我的角度应用程序从5.2升级到版本6.一切正常但是当我尝试从IntelliJ运行测试时会抛出以下错误:

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. 错误:'@ angular-devkit / build-angular / plugins / karma'karma插件意味着在Angular CLI中使用,并且无法在其外部正常工作。

In the previous version i could run the same test from IntelliJ. 在之前的版本中,我可以从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: 这是我的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" } }

Known issue, caused by recent changes in Angular CLI. 由Angular CLI最近的更改引起的已知问题。 Here's an issue about that in the angular-cli repo: https://github.com/angular/angular-cli/issues/10703 . 这是angular-cli repo中的一个问题: https//github.com/angular/angular-cli/issues/10703 Related JetBrains ticket: WEB-32653 . 相关的JetBrains门票: WEB-32653 Please follow it for updates 请关注它以获取更新

Although this Issue got fixed in Version 2018.3 but I had to some settings modification. 虽然此问题在版本2018.3中得到修复,但我不得不进行一些设置修改。

I ended up fixing this in IntelliJ's Web Storm : 我最终在IntelliJ的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 运行>编辑配置>运行/调试配置>左侧面板(Seleck Karma和特定测试)>将karma包更改为〜\\ 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 检查一下 - > https://github.com/angular/angular-cli/issues/12108

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM