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

Using autoWatch with a **/* glob doesn't update the reports #2203

Open
shairez opened this issue Jun 27, 2016 · 1 comment
Open

Using autoWatch with a **/* glob doesn't update the reports #2203

shairez opened this issue Jun 27, 2016 · 1 comment

Comments

@shairez
Copy link

shairez commented Jun 27, 2016

Expected behavior

autoWatch should work and report correct results with glob matchers of src/app/**/*.js

Actual behavior

Reports are not updating to the correct result in autoWatch when using a matcher like src/app/**/*.js

Enviroment Details

  • Karma version (output of karma --version):
    1.1.0
  • Relevant part of your karma.config.js file
    files

Steps to reproduce the behaviour

I've prepared an example project at -
https://github.com/shairez/karma-autowatch-problem-example

  • Before going through the steps below, clone the project

Here are the steps:

  1. karma start
  2. Verify that you see the Executed 1 of 1 SUCCESS message
  3. Go to registration.component.spec.js
  4. On line 25 change ctrl.createAccount() to ctrl.createAccount2()
  5. You should see a failing test message in the karma report, but you see the same SUCCESS message from before

It is solved when you change the glob matcher

I managed to find out that it's got to do with the glob matcher in the files configuration in karma.conf.js.

  1. Go to karma.conf.js,
  2. Comment line 12 where it says 'src/app/**/*.js'
  3. Uncomment line 13 where it says 'src/app/**/*.{component,service}.js'
  4. You should now see the autoWatch works correctly

Bottom line

Something with 'src/app/**/*.js' breaks the autoWatch reporting behavior

@wesleycho
Copy link
Member

The breakage here turns out to be due to the overly broad pattern of src/app/**/*.js - it turns out that this problem is not only limited to the test file being changed, but the watcher failing for any other file modified that falls under a subset of this pattern. One can add throw 'foo' to app.module.js and also see this fail.

What looks like is happening here is that there is a stale promise at https://github.com/karma-runner/karma/blob/master/lib/file-list.js#L346 . If one replaces that line with this.refresh(), this works, but it will cause the test runner to run twice. It is as if karma is serving files from memory instead of the direct file, so the stale ones are run again, which results in the stale test result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants