Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng test does not react properly when detecting a code change #13542

Closed
FrancescoBorzi opened this issue Jan 29, 2019 · 5 comments
Closed

ng test does not react properly when detecting a code change #13542

FrancescoBorzi opened this issue Jan 29, 2019 · 5 comments

Comments

@FrancescoBorzi
Copy link

As requested by @filipesilva, I tested this issue again on a newer CLI version: #9901

The result is that the bug is exactly the same as before. As described in the original issue.

I post here my new ng --version as well as the (same) description of the bug.

Versions

Angular CLI: 7.2.3
Node: 10.15.0
OS: linux x64
Angular: 7.2.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.12.3
@angular-devkit/build-angular     0.12.3
@angular-devkit/build-optimizer   0.12.3
@angular-devkit/build-webpack     0.12.3
@angular-devkit/core              7.2.3
@angular-devkit/schematics        7.2.3
@angular/cli                      7.2.3
@ngtools/webpack                  7.2.3
@schematics/angular               7.2.3
@schematics/update                0.12.3
rxjs                              6.3.3
typescript                        3.2.4
webpack                           4.28.4

Repro steps

  • Setup an Angular app with many unit test cases
  • Run your unit tests
  • While they are running, change a file and force to run a single case set to run (by using fdescribe or fit)

Observed behavior

It will recompile (or at least it looks like it) but it will still keep continuing the previous run instead of starting a new one with the specific test cases set.

So every time I need to use fdescribe or fit I need either to wait that the current test run finishes or I have to manually kill and restart `ng test

Desired behavior

Whenever something changes in the code, ng test should just recompile and rerun again from the beginning and taking into account any changes related to the test cases set to run (e.g. any usage of fdescribe or fit should be taken into account without the need of restarting the cli process)

@filipesilva
Copy link
Contributor

@FrancescoBorzi thank you for testing this on the latest version again. I agree with you that this behaviour is a bug because the previous run should be interrupted.

@confraria
Copy link
Contributor

confraria commented Feb 7, 2019

There is an karma configuration option for this: { restartOnFileChange: true }

and this is what it does in karma/lib/server.js

if (config.autoWatch) {
      this.on('file_list_modified', () => {
        this.log.debug('List of files has changed, trying to execute')
        if (config.restartOnFileChange) {
          socketServer.sockets.emit('stop')
        }
        executor.schedule()
      })
    }

@FrancescoBorzi could you check if this option works for you?

should I do a PR to include this in packages/schematics/angular/application/files/root/karma.conf.js.template ?

@FrancescoBorzi
Copy link
Author

@confraria thanks, it looks like it's working. However there is a small defect (after putting some fit):

image

it says "Executed X tests of null` so it doesn't say the total amount of tests that are there.

@filipesilva
Copy link
Contributor

@confraria yes that definitely sounds like we should use as a default. Can you make a PR please?

@FrancescoBorzi does it go back to saying the right total after the first run, or does it always say null now?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants