Angular CLI 6.0.0 and Karma: Karma server don't rebuild code changes

Hi!

I'm using the current WebStorm 2018.1.4 and the standard Angular CLI 6.0.0 Karma configuration. If I try to test changed code, the karma server doesn't rebuild the source and its currently testing the code it built first. I have to restart the Karma server to run new tests. Is this a bug or do I have to restart the Karma server every time? 

In karma.conf.js the option autoWatch is set to true. 

Thanks in advance!

13 comments

Can't recreate - I don't need restarting the server, re-running the tests is enough

>In karma.conf.js the option autoWatch is set to true

Karma watch mode is not supported, please vote for https://youtrack.jetbrains.com/issue/WEB-14437. But you can enable auto-test mode in webstorm by pressing the corresponding button in Test Run toolwindow - tests will be re-run automatically on changes

0

Hi, 

thanks for the answer. It's a bit strange, after I updated all packages to the newest version (cli, @angular-devkit/build-angular,...) it works. 

 

 

1

I am having a similar problem in WebStorm 2018.1.4. With auto-test enabled (as in the image above), web storm re-runs the tests when I make code changes. However, in the terminal for the Karma server, I do not see a corresponding build step for webpack and so the test result always reflect the code at the point I started the test run.

I think there needs to be a trigger to cause a re-build of the code and then re-run the test suite.

0

this is controlled by angular-cli, I believe...

Can you share a project that can be used to recreate the issue?

0

I will make a reduced case for you as I can't share my current project

0

I made a project from scratch and couldn't reproduce. Upgrading several dependencies solved my problem. In case any one else experiences this problem my diff was:

diff --git a/package.json b/package.json
index b9600021..0a595e44 100644
--- a/package.json
+++ b/package.json
@@ -76,7 +76,7 @@
"zone.js": "^0.8.26"
},
"devDependencies": {
- "@angular-devkit/build-angular": "~0.5.13",
+ "@angular-devkit/build-angular": "~0.6.1",
"@angular/cli": "6.0.7",
"@angular/compiler-cli": "^6.0.3",
"@angular/language-service": "^6.0.3",
@@ -84,8 +84,8 @@
"@types/file-saver": "^1.3.0",
"@types/grunt": "^0.4.22",
"@types/highcharts": "^5.0.22",
- "@types/jasmine": "2.5.53",
- "@types/jasminewd2": "^2.0.3",
+ "@types/jasmine": "~2.8.6",
+ "@types/jasminewd2": "~2.0.3",
"@types/jquery": "^3.3.2",
"@types/lodash": "^4.14.109",
"@types/mousetrap": "^1.6.0",
@@ -104,19 +104,18 @@
"grunt-http": "^2.3.1",
"grunt-prompt": "^1.3.3",
"grunt-release": "^0.14.0",
- "jasmine-core": "~2.6.2",
- "jasmine-spec-reporter": "~4.1.0",
- "karma": "~1.7.0",
- "karma-chrome-launcher": "~2.1.1",
- "karma-cli": "~1.0.1",
- "karma-coverage-istanbul-reporter": "^1.4.2",
- "karma-jasmine": "^1.1.2",
+ "jasmine-core": "~2.99.1",
+ "jasmine-spec-reporter": "~4.2.1",
+ "karma": "~1.7.1",
+ "karma-chrome-launcher": "~2.2.0",
+ "karma-coverage-istanbul-reporter": "~1.4.2",
+ "karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"load-grunt-tasks": "^3.5.2",
"ngx-easy-test": "^1.1.0",
"prettier": "^1.13.2",
"script-loader": "^0.7.2",
- "ts-node": "^3.3.0",
+ "ts-node": "~5.0.1",
"tslint": "^5.10.0",
"typescript": "~2.7.2",
"webpack-bundle-analyzer": "^2.13.1"

1

I can reproduce this issue with node v10.3.0. Auto-test doesn't work and I need to stop karma server between each run to get a fresh result.

On the contrary, everything works fine with node v8.9. 

0

That's interesting. I was using Node v8.9

0

JON, please provide a sample project we can use to reproduce the issue. Also, what IDE version do you use?

0

Made some tests to reproduce this. Here is my configuration and what I do.

Configuration:

  • node v10.4.1
  • webstorm 2018.1.4
  • angular 6.0.8

Steps to reproduce:

  1. Create project : ng new foo -t -s --routing --style scss
  2. Open project in webstorm
  3. Run karma.conf.js
  4. Third test is in error
  5. Fix it
  6. Run tests again => modification not taken into account
  7. Run again => modification taken into account => Second test in now in error
  8. Fix it
  9. Run tests again => modification not taken into account
  10. Run again => modification taken into account => All tests are now green

Once all tests are green, the bug is no longer present. You can modify and run. Your modifications are taken into account immediately.

The same thing happen whether you use auto-watch or not.

Here is a newly generated project in case.

 

0

I'm not permitted to access the project, and I can't recreate the issue with a new 6.0.3 app created per instructions above  + Node.js 10.4.1:(

Please can you grant me a permission to download the project?

 

0

Oups, sorry, I updated the link above. I'm using angular 6.0.8, not 6.0.3.

0

Thanks for the link!

Still no luck unfortunately - I can't recreate the issue using provided steps.

Please can you record a video (using your example project) that shows up the isue? I might be doing smth wrong...

I'm using the most recent cli:

Angular CLI: 6.1.0-beta.0
Node: 10.4.1
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.7.0-beta.0
@angular-devkit/core         0.7.0-beta.0
@angular-devkit/schematics   0.7.0-beta.0
@schematics/angular          0.7.0-beta.0
@schematics/update           0.7.0-beta.0
rxjs                         6.2.1
typescript                   2.7.2

0

Please sign in to leave a comment.